Repository: moov-io/customers
Pull request #192 (2020-09-24 16:07:36)

set logger for database migrator (instead of default stdout)
Send migrator output to log instead of stdout


Patch:
diff --git a/cmd/server/main.go b/cmd/server/main.go
index 621c082..ca14102 100644
--- a/cmd/server/main.go
+++ b/cmd/server/main.go
@@ -25,8 +25,6 @@ import (
 	"github.com/moov-io/customers/pkg/accounts"
 	"github.com/moov-io/customers/pkg/configuration"
 	"github.com/moov-io/customers/pkg/customers"
-	"github.com/moov-io/customers/pkg/documents"
-	"github.com/moov-io/customers/pkg/documents/storage"
 	"github.com/moov-io/customers/pkg/fed"
 	"github.com/moov-io/customers/pkg/paygate"
 	"github.com/moov-io/customers/pkg/secrets"
@@ -34,7 +32,6 @@ import (
 	"github.com/moov-io/customers/pkg/validator/microdeposits"
 	"github.com/moov-io/customers/pkg/validator/mx"
 	"github.com/moov-io/customers/pkg/validator/plaid"
-	"github.com/moov-io/customers/pkg/watchman"
 
 	"github.com/go-kit/kit/log"
 	"github.com/gorilla/mux"
@@ -92,8 +89,8 @@ func main() {
 	accountsRepo := accounts.NewRepo(logger, db)
 	customerRepo := customers.NewCustomerRepo(logger, db)
 	customerSSNRepo := customers.NewCustomerSSNRepository(logger, db)
-	disclaimerRepo := documents.NewDisclaimerRepo(logger, db)
-	documentRepo := documents.NewDocumentRepo(logger, db)
+	disclaimerRepo := customers.NewDisclaimerRepo(logger, db)
+	documentRepo := customers.NewDocumentRepo(logger, db)
 	validationsRepo := validator.NewRepo(db)
 
 	// Start Admin server (with Prometheus metrics)
@@ -123,7 +120,7 @@ func main() {
 	// Create our Watchman client
 	debugWatchmanCalls := util.Or(os.Getenv("WATCHMAN_DEBUG_CALLS"), "false")
 	watchmanEndpoint := util.Or(os.Getenv("WATCHMAN_ENDPOINT"), os.Getenv("OFAC_ENDPOINT"))
-	watchmanClient := watchman.NewClient(logger, watchmanEndpoint, util.Yes(debugWatchmanCalls))
+	watchmanClient := customers.NewWatchmanClient(logger, watchmanEndpoint, util.Yes(debugWatchmanCalls))
 	if watchmanClient == nil {
 		panic("No Watchman client created, see WATCHMAN_ENDPOINT")
 	}
@@ -132,7 +129,7 @@ func main() {
 
 	// Register our admin routes
 	customers.AddApprovalRoutes(logger, adminServer, customerRepo, customerSSNRepo, ofac)
-	documents.AddDisclaimerAdminRoutes(logger, adminServer, disclaimerRepo, documentRepo)
+	customers.AddDisclaimerAdminRoutes(logger, adminServer, disclaimerRepo, documentRepo)
 
 	// Setup Customer SSN storage wrapper
 	ctx := context.Background()
@@ -170,8 +167,8 @@ func main() {
 	addPingRoute(router)
 	accounts.RegisterRoutes(logger, router, accountsRepo, validationsRepo, fedClient, stringKeeper, transitStringKeeper, validationStrategies, &accountOfacSeacher)
 	customers.AddCustomerRoutes(logger, router, customerRepo, customerSSNStorage, ofac)
-	documents.AddDisclaimerRoutes(logger, router, disclaimerRepo)
-	documents.AddDocumentRoutes(logger, router, documentRepo, storage.GetBucket(bucketName, cloudProvider, signer))
+	customers.AddDisclaimerRoutes(logger, router, disclaimerRepo)
+	customers.AddDocumentRoutes(logger, router, documentRepo, customers.GetBucket(bucketName, cloudProvider, signer))
 	customers.AddOFACRoutes(logger, router, customerRepo, ofac)
 
 	// Add Configuration routes
@@ -181,7 +178,7 @@ func main() {
 	// Optionally serve /files/ as our fileblob routes
 	// Note: FILEBLOB_BASE_URL needs to match something that's routed to /files/...
 	if cloudProvider == "file" {
-		storage.AddFileblobRoutes(logger, router, signer, storage.GetBucket(bucketName, cloudProvider, signer))
+		customers.AddFileblobRoutes(logger, router, signer, customers.GetBucket(bucketName, cloudProvider, signer))
 	}
 
 	// Start business HTTP server
@@ -248,7 +245,7 @@ func setupStorageBucket(logger log.Logger, bucketName, cloudProvider string) *fi
 			secret = "secret"
 			logger.Log("main", "WARNING!!!! USING INSECURE DEFAULT FILE STORAGE, set FILEBLOB_HMAC_SECRET for ANY production usage")
 		}
-		signer, err := storage.FileblobSigner(baseURL, secret)
+		signer, err := customers.FileblobSigner(baseURL, secret)
 		if err != nil {
 			panic(fmt.Sprintf("fileBucket: %v", err))
 		}
diff --git a/internal/database/mysql.go b/internal/database/mysql.go
index 01f45f0..d964a47 100644
--- a/internal/database/mysql.go
+++ b/internal/database/mysql.go
@@ -161,8 +161,12 @@ func (my *mysql) Connect() (*sql.DB, error) {
 		return nil, err
 	}
 
+	migratorLogger := migrator.WithLogger(migrator.LoggerFunc(func(msg string, args ...interface{}) {
+		my.logger.Log("mysql", msg)
+	}))
+
 	// Migrate our database
-	if m, err := migrator.New(mysqlMigrations); err != nil {
+	if m, err := migrator.New(migratorLogger, mysqlMigrations); err != nil {
 		return nil, err
 	} else {
 		if err := m.Migrate(db); err != nil {
diff --git a/internal/database/sqlite.go b/internal/database/sqlite.go
index beaaa62..614f4e6 100644
--- a/internal/database/sqlite.go
+++ b/internal/database/sqlite.go
@@ -177,8 +177,12 @@ func (s *sqlite) Connect() (*sql.DB, error) {
 		return db, err
 	}
 
+	migratorLogger := migrator.WithLogger(migrator.LoggerFunc(func(msg string, args ...interface{}) {
+		s.logger.Log("sqlite", msg)
+	}))
+
 	// Migrate our database
-	if m, err := migrator.New(sqliteMigrations); err != nil {
+	if m, err := migrator.New(migratorLogger, sqliteMigrations); err != nil {
 		return db, err
 	} else {
 		if err := m.Migrate(db); err != nil {
diff --git a/pkg/accounts/accounts_ofac.go b/pkg/accounts/accounts_ofac.go
index 0e2ef43..0afdd41 100644
--- a/pkg/accounts/accounts_ofac.go
+++ b/pkg/accounts/accounts_ofac.go
@@ -3,16 +3,21 @@ package accounts
 import (
 	"context"
 	"fmt"
-	"time"
-
 	"github.com/moov-io/customers/pkg/client"
-	"github.com/moov-io/customers/pkg/watchman"
+	watchman "github.com/moov-io/watchman/client"
 	"github.com/pkg/errors"
+	"time"
 )
 
 type AccountOfacSearcher struct {
 	Repo           Repository
-	WatchmanClient watchman.Client
+	WatchmanClient WatchmanClient
+}
+
+type WatchmanClient interface {
+	Ping() error
+
+	Search(ctx context.Context, name string, requestID string) (*watchman.OfacSdn, error)
 }
 
 // StoreAccountOFACSearch performs OFAC searches against the Account's HolderName and nickname if populated.
@@ -33,9 +38,6 @@ func (s *AccountOfacSearcher) StoreAccountOFACSearch(account *client.Account, re
 	if err != nil {
 		return fmt.Errorf("AccountOfacSearcher.StoreAccountOFACSearch: name search for account=%s: %v", account.AccountID, err)
 	}
-	if sdn == nil {
-		return nil
-	}
 	err = s.Repo.saveAccountOFACSearch(account.AccountID, &client.OfacSearch{
 		EntityID:  sdn.EntityID,
 		SdnName:   sdn.SdnName,
diff --git a/pkg/customers/approval_ofac.go b/pkg/customers/approval_ofac.go
index 928ead1..738e3d9 100644
--- a/pkg/customers/approval_ofac.go
+++ b/pkg/customers/approval_ofac.go
@@ -15,8 +15,7 @@ import (
 	moovhttp "github.com/moov-io/base/http"
 	"github.com/moov-io/customers/pkg/client"
 	"github.com/moov-io/customers/pkg/route"
-	"github.com/moov-io/customers/pkg/watchman"
-	watchmanClient "github.com/moov-io/watchman/client"
+	watchman "github.com/moov-io/watchman/client"
 
 	"github.com/go-kit/kit/log"
 	"github.com/gorilla/mux"
@@ -32,10 +31,10 @@ type ofacSearchResult struct {
 
 type OFACSearcher struct {
 	repo           CustomerRepository
-	watchmanClient watchman.Client
+	watchmanClient WatchmanClient
 }
 
-func NewOFACSearcher(repo CustomerRepository, client watchman.Client) *OFACSearcher {
+func NewOFACSearcher(repo CustomerRepository, client WatchmanClient) *OFACSearcher {
 	return &OFACSearcher{
 		repo:           repo,
 		watchmanClient: client,
@@ -56,7 +55,7 @@ func (s *OFACSearcher) storeCustomerOFACSearch(cust *client.Customer, requestID
 	if err != nil {
 		return fmt.Errorf("OFACSearcher.storeCustomerOFACSearch: name search for customer=%s: %v", cust.CustomerID, err)
 	}
-	var nickSDN *watchmanClient.OfacSdn
+	var nickSDN *watchman.OfacSdn
 	if cust.NickName != "" {
 		nickSDN, err = s.watchmanClient.Search(ctx, cust.NickName, requestID)
 		if err != nil {
diff --git a/pkg/documents/storage/bucket.go b/pkg/customers/bucket.go
similarity index 96%
rename from pkg/documents/storage/bucket.go
rename to pkg/customers/bucket.go
index 90d6006..a4fa6e4 100644
--- a/pkg/documents/storage/bucket.go
+++ b/pkg/customers/bucket.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by an Apache License
 // license that can be found in the LICENSE file.
 
-package storage
+package customers
 
 import (
 	"context"
@@ -22,9 +22,9 @@ import (
 	"gocloud.dev/gcp"
 )
 
-type BucketFunc func() (*blob.Bucket, error)
+type bucketFunc func() (*blob.Bucket, error)
 
-func GetBucket(bucketName, cloudProvider string, FileblobSigner *fileblob.URLSignerHMAC) BucketFunc {
+func GetBucket(bucketName, cloudProvider string, FileblobSigner *fileblob.URLSignerHMAC) bucketFunc {
 	return func() (*blob.Bucket, error) {
 		ctx, cancelFn := context.WithTimeout(context.TODO(), 10*time.Second)
 		defer cancelFn()
diff --git a/pkg/documents/disclaimers.go b/pkg/customers/disclaimers.go
similarity index 99%
rename from pkg/documents/disclaimers.go
rename to pkg/customers/disclaimers.go
index 3b660c8..6698367 100644
--- a/pkg/documents/disclaimers.go
+++ b/pkg/customers/disclaimers.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by an Apache License
 // license that can be found in the LICENSE file.
 
-package documents
+package customers
 
 import (
 	"database/sql"
diff --git a/pkg/documents/documents.go b/pkg/customers/documents.go
similarity index 97%
rename from pkg/documents/documents.go
rename to pkg/customers/documents.go
index 1b65fa8..ac08e18 100644
--- a/pkg/documents/documents.go
+++ b/pkg/customers/documents.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by an Apache License
 // license that can be found in the LICENSE file.
 
-package documents
+package customers
 
 import (
 	"bytes"
@@ -20,7 +20,6 @@ import (
 	moovhttp "github.com/moov-io/base/http"
 
 	"github.com/moov-io/customers/pkg/client"
-	"github.com/moov-io/customers/pkg/documents/storage"
 	"github.com/moov-io/customers/pkg/route"
 
 	"github.com/go-kit/kit/log"
@@ -34,7 +33,7 @@ var (
 	maxDocumentSize int64 = 20 * 1024 * 1024 // 20MB
 )
 
-func AddDocumentRoutes(logger log.Logger, r *mux.Router, repo DocumentRepository, bucketFactory storage.BucketFunc) {
+func AddDocumentRoutes(logger log.Logger, r *mux.Router, repo DocumentRepository, bucketFactory bucketFunc) {
 	r.Methods("GET").Path("/customers/{customerID}/documents").HandlerFunc(getCustomerDocuments(logger, repo))
 	r.Methods("POST").Path("/customers/{customerID}/documents").HandlerFunc(uploadCustomerDocument(logger, repo, bucketFactory))
 	r.Methods("GET").Path("/customers/{customerID}/documents/{documentId}").HandlerFunc(retrieveRawDocument(logger, repo, bucketFactory))
@@ -83,7 +82,7 @@ func readDocumentType(v string) (string, error) {
 	return "", fmt.Errorf("unknown Document type: %s", orig)
 }
 
-func uploadCustomerDocument(logger log.Logger, repo DocumentRepository, bucketFactory storage.BucketFunc) http.HandlerFunc {
+func uploadCustomerDocument(logger log.Logger, repo DocumentRepository, bucketFactory bucketFunc) http.HandlerFunc {
 	return func(w http.ResponseWriter, r *http.Request) {
 		w = route.Responder(logger, w, r)
 		// TODO(adam): should we store x-namespace along with the Document?
@@ -164,7 +163,7 @@ func uploadCustomerDocument(logger log.Logger, repo DocumentRepository, bucketFa
 	}
 }
 
-func retrieveRawDocument(logger log.Logger, repo DocumentRepository, bucketFactory storage.BucketFunc) http.HandlerFunc {
+func retrieveRawDocument(logger log.Logger, repo DocumentRepository, bucketFactory bucketFunc) http.HandlerFunc {
 	return func(w http.ResponseWriter, r *http.Request) {
 		w = route.Responder(logger, w, r)
 
diff --git a/pkg/documents/storage/files.go b/pkg/customers/files.go
similarity index 93%
rename from pkg/documents/storage/files.go
rename to pkg/customers/files.go
index 40a5042..3fca817 100644
--- a/pkg/documents/storage/files.go
+++ b/pkg/customers/files.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by an Apache License
 // license that can be found in the LICENSE file.
 
-package storage
+package customers
 
 import (
 	"context"
@@ -21,7 +21,7 @@ import (
 	"gocloud.dev/blob/fileblob"
 )
 
-func AddFileblobRoutes(logger log.Logger, r *mux.Router, signer *fileblob.URLSignerHMAC, bucketFactory BucketFunc) {
+func AddFileblobRoutes(logger log.Logger, r *mux.Router, signer *fileblob.URLSignerHMAC, bucketFactory bucketFunc) {
 	if v := os.Getenv("FILEBLOB_BASE_URL"); v != "" {
 		u, err := url.Parse(v)
 		if u != nil && err == nil {
@@ -32,7 +32,7 @@ func AddFileblobRoutes(logger log.Logger, r *mux.Router, signer *fileblob.URLSig
 	}
 }
 
-func proxyLocalFile(logger log.Logger, signer *fileblob.URLSignerHMAC, bucketFactory BucketFunc) http.HandlerFunc {
+func proxyLocalFile(logger log.Logger, signer *fileblob.URLSignerHMAC, bucketFactory bucketFunc) http.HandlerFunc {
 	return func(w http.ResponseWriter, r *http.Request) {
 		w = route.Responder(logger, w, r)
 
diff --git a/pkg/watchman/watchman.go b/pkg/customers/watchman.go
similarity index 96%
rename from pkg/watchman/watchman.go
rename to pkg/customers/watchman.go
index 2f870a6..f18f28d 100644
--- a/pkg/watchman/watchman.go
+++ b/pkg/customers/watchman.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by an Apache License
 // license that can be found in the LICENSE file.
 
-package watchman
+package customers
 
 import (
 	"context"
@@ -17,7 +17,7 @@ import (
 	"github.com/go-kit/kit/log"
 )
 
-type Client interface {
+type WatchmanClient interface {
 	Ping() error
 
 	Search(ctx context.Context, name string, requestID string) (*watchman.OfacSdn, error)
@@ -157,12 +157,12 @@ func (c *moovWatchmanClient) Search(ctx context.Context, name string, requestID
 	return nil, nil // Nothing found
 }
 
-// NewClient returns an WatchmanClient instance and will default to using the Watchman address in
+// NewWatchmanClient returns an WatchmanClient instance and will default to using the Watchman address in
 // moov's standard Kubernetes setup.
 //
 // endpoint is a DNS record responsible for routing us to an Watchman instance.
 // Example: http://watchman.apps.svc.cluster.local:8080
-func NewClient(logger log.Logger, endpoint string, debug bool) Client {
+func NewWatchmanClient(logger log.Logger, endpoint string, debug bool) WatchmanClient {
 	conf := watchman.NewConfiguration()
 	conf.BasePath = "http://localhost" + bind.HTTP("watchman")
 	conf.Debug = debug
diff --git a/pkg/documents/testdata/colorado.jpg b/testdata/colorado.jpg
similarity index 100%
rename from pkg/documents/testdata/colorado.jpg
rename to testdata/colorado.jpg
diff --git a/version.go b/version.go
index 3bea6eb..0a5002f 100644
--- a/version.go
+++ b/version.go
@@ -5,4 +5,4 @@
 package customers
 
 // Version number
-const Version = "v0.5.0-dev10"
+const Version = "v0.5.0-dev4"


Test patch:
diff --git a/pkg/accounts/accounts_ofac_test.go b/pkg/accounts/accounts_ofac_test.go
index c6b7ff4..397b779 100644
--- a/pkg/accounts/accounts_ofac_test.go
+++ b/pkg/accounts/accounts_ofac_test.go
@@ -5,26 +5,13 @@
 package accounts
 
 import (
-	"testing"
-
 	"github.com/moov-io/customers/pkg/client"
-	"github.com/moov-io/customers/pkg/watchman"
-	watchmanClient "github.com/moov-io/watchman/client"
+	"testing"
 )
 
 func TestStoreAccountOFACSearchSuccess(t *testing.T) {
 	mockRepository := mockRepository{}
-	watchmanClient := watchman.NewTestWatchmanClient(&watchmanClient.OfacSdn{
-		EntityID: "123",
-		SdnName:  "dummy_sdn",
-		SdnType:  "dummy_sdn_type",
-		Programs: nil,
-		Title:    "dummy_title",
-		Remarks:  "dummy_remarks",
-		Match:    10.2,
-	}, nil)
-
-	accountOfacSearcher := createTestOFACSearcher(&mockRepository, watchmanClient)
+	accountOfacSearcher := createTestOFACSearcher(&mockRepository, nil)
 	requestID := "someRequestId"
 	account := &client.Account{
 		AccountID:  "123",
diff --git a/pkg/accounts/router_test.go b/pkg/accounts/router_test.go
index 139824e..6ce6bda 100644
--- a/pkg/accounts/router_test.go
+++ b/pkg/accounts/router_test.go
@@ -15,27 +15,55 @@ import (
 	"strings"
 	"testing"
 
-	"github.com/moov-io/base"
+	watchman "github.com/moov-io/watchman/client"
+	"github.com/stretchr/testify/assert"
+
 	"github.com/moov-io/customers/internal/testclient"
+
+	"github.com/moov-io/base"
+	"github.com/stretchr/testify/require"
+
 	"github.com/moov-io/customers/pkg/client"
 	"github.com/moov-io/customers/pkg/fed"
 	"github.com/moov-io/customers/pkg/secrets"
+
 	"github.com/moov-io/customers/pkg/validator"
 	"github.com/moov-io/customers/pkg/validator/testvalidator"
-	"github.com/moov-io/customers/pkg/watchman"
 
 	"github.com/go-kit/kit/log"
 	"github.com/gorilla/mux"
-	"github.com/stretchr/testify/assert"
-	"github.com/stretchr/testify/require"
 )
 
-func createTestOFACSearcher(repo Repository, watchmanClient watchman.Client) *AccountOfacSearcher {
+type testWatchmanClient struct {
+	// error to be returned instead of field from above
+	err error
+}
+
+func (c *testWatchmanClient) Ping() error {
+	return c.err
+}
+
+func (c *testWatchmanClient) Search(_ context.Context, name string, _ string) (*watchman.OfacSdn, error) {
+	if c.err != nil {
+		return nil, c.err
+	}
+	return &watchman.OfacSdn{
+		EntityID: "123",
+		SdnName:  "dummy_sdn",
+		SdnType:  "dummy_sdn_type",
+		Programs: nil,
+		Title:    "dummy_title",
+		Remarks:  "dummy_remarks",
+		Match:    10.2,
+	}, nil
+}
+
+func createTestOFACSearcher(repo Repository, watchmanClient WatchmanClient) *AccountOfacSearcher {
 	if repo == nil {
 		repo = &testAccountRepository{}
 	}
 	if watchmanClient == nil {
-		watchmanClient = watchman.NewTestWatchmanClient(nil, nil)
+		watchmanClient = &testWatchmanClient{}
 	}
 	return &AccountOfacSearcher{Repo: repo, WatchmanClient: watchmanClient}
 }
diff --git a/pkg/customers/approval_ofac_test.go b/pkg/customers/approval_ofac_test.go
index 1b57902..c810394 100644
--- a/pkg/customers/approval_ofac_test.go
+++ b/pkg/customers/approval_ofac_test.go
@@ -16,25 +16,24 @@ import (
 	"github.com/gorilla/mux"
 	"github.com/moov-io/base"
 	"github.com/moov-io/customers/pkg/client"
-	"github.com/moov-io/customers/pkg/watchman"
-	watchmanClient "github.com/moov-io/watchman/client"
+	watchman "github.com/moov-io/watchman/client"
 )
 
-func createTestOFACSearcher(repo CustomerRepository, client watchman.Client) *OFACSearcher {
+func createTestOFACSearcher(repo CustomerRepository, watchmanClient WatchmanClient) *OFACSearcher {
 	if repo == nil {
 		repo = &testCustomerRepository{}
 	}
-	if client == nil {
-		client = &watchman.TestWatchmanClient{}
+	if watchmanClient == nil {
+		watchmanClient = &testWatchmanClient{}
 	}
-	return &OFACSearcher{repo: repo, watchmanClient: client}
+	return &OFACSearcher{repo: repo, watchmanClient: watchmanClient}
 }
 
 func TestOFACSearcher__nil(t *testing.T) {
 	repo := createTestCustomerRepository(t)
 	defer repo.close()
 
-	ofacClient := &watchman.TestWatchmanClient{}
+	ofacClient := &testWatchmanClient{}
 	searcher := createTestOFACSearcher(repo, ofacClient)
 
 	if err := searcher.storeCustomerOFACSearch(nil, "requestID"); err == nil {
@@ -46,13 +45,14 @@ func TestOFACSearcher__storeCustomerOFACSearch(t *testing.T) {
 	repo := createTestCustomerRepository(t)
 	defer repo.close()
 
-	ofacClient := watchman.NewTestWatchmanClient(&watchmanClient.OfacSdn{
+	ofacClient := &testWatchmanClient{}
+	searcher := createTestOFACSearcher(repo, ofacClient)
+
+	ofacClient.sdn = &watchman.OfacSdn{
 		EntityID: "1241421",
 		SdnName:  "Jane Doe",
 		Match:    0.99,
-	}, nil)
-	searcher := createTestOFACSearcher(repo, ofacClient)
-
+	}
 	customerID := base.ID()
 	if err := searcher.storeCustomerOFACSearch(&client.Customer{CustomerID: customerID}, "requestID"); err != nil {
 		t.Fatal(err)
@@ -129,7 +129,7 @@ func TestOFACApproval__refresh(t *testing.T) {
 			Match:    1.0,
 		},
 	}
-	testWatchmanClient := watchman.NewTestWatchmanClient(nil, nil)
+	testWatchmanClient := &testWatchmanClient{}
 	ofac := &OFACSearcher{
 		repo:           repo,
 		watchmanClient: testWatchmanClient,
@@ -179,7 +179,7 @@ func TestOFACApproval__refreshErr(t *testing.T) {
 			Match:    0.88,
 		},
 	}
-	testWatchmanClient := watchman.NewTestWatchmanClient(nil, errors.New("bad error"))
+	testWatchmanClient := &testWatchmanClient{err: errors.New("bad error")}
 	ofac := &OFACSearcher{
 		repo:           repo,
 		watchmanClient: testWatchmanClient,
diff --git a/pkg/documents/storage/bucket_test.go b/pkg/customers/bucket_test.go
similarity index 76%
rename from pkg/documents/storage/bucket_test.go
rename to pkg/customers/bucket_test.go
index 414b126..990b2ab 100644
--- a/pkg/documents/storage/bucket_test.go
+++ b/pkg/customers/bucket_test.go
@@ -2,12 +2,31 @@
 // Use of this source code is governed by an Apache License
 // license that can be found in the LICENSE file.
 
-package storage
+package customers
 
 import (
 	"context"
+	"fmt"
 	"io/ioutil"
 	"testing"
+	"time"
+
+	"gocloud.dev/blob"
+)
+
+var (
+	testBucket bucketFunc = func() (*blob.Bucket, error) {
+		signer, err := FileblobSigner("http://localhost:8087", "secret")
+		if err != nil {
+			panic(fmt.Sprintf("testBucket: %v", err))
+		}
+
+		ctx, cancelFn := context.WithTimeout(context.TODO(), 1*time.Second)
+		defer cancelFn()
+
+		dir, _ := ioutil.TempDir("", "testBucket")
+		return fileBucket(ctx, dir, signer)
+	}
 )
 
 func TestBucket__openBucket(t *testing.T) {
diff --git a/pkg/documents/disclaimers_test.go b/pkg/customers/disclaimers_test.go
similarity index 99%
rename from pkg/documents/disclaimers_test.go
rename to pkg/customers/disclaimers_test.go
index 9dfad0f..d81ca71 100644
--- a/pkg/documents/disclaimers_test.go
+++ b/pkg/customers/disclaimers_test.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by an Apache License
 // license that can be found in the LICENSE file.
 
-package documents
+package customers
 
 import (
 	"bytes"
diff --git a/pkg/documents/documents_test.go b/pkg/customers/documents_test.go
similarity index 95%
rename from pkg/documents/documents_test.go
rename to pkg/customers/documents_test.go
index 48143f8..0b471c0 100644
--- a/pkg/documents/documents_test.go
+++ b/pkg/customers/documents_test.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by an Apache License
 // license that can be found in the LICENSE file.
 
-package documents
+package customers
 
 import (
 	"bytes"
@@ -25,7 +25,6 @@ import (
 
 	"github.com/moov-io/customers/internal/database"
 	"github.com/moov-io/customers/pkg/client"
-	"github.com/moov-io/customers/pkg/documents/storage"
 
 	"github.com/go-kit/kit/log"
 	"github.com/gorilla/mux"
@@ -74,7 +73,7 @@ func TestDocuments__getCustomerDocuments(t *testing.T) {
 	req.Header.Set("x-request-id", "test")
 
 	router := mux.NewRouter()
-	AddDocumentRoutes(log.NewNopLogger(), router, repo, storage.TestBucket)
+	AddDocumentRoutes(log.NewNopLogger(), router, repo, testBucket)
 	router.ServeHTTP(w, req)
 	w.Flush()
 
@@ -121,7 +120,7 @@ func TestDocuments__readDocumentType(t *testing.T) {
 }
 
 func multipartRequest(t *testing.T) *http.Request {
-	fd, err := os.Open(filepath.Join("testdata", "colorado.jpg"))
+	fd, err := os.Open(filepath.Join("..", "..", "testdata", "colorado.jpg"))
 	if err != nil {
 		t.Fatal(err)
 	}
@@ -157,7 +156,7 @@ func TestDocumentsUploadAndRetrieval(t *testing.T) {
 	req.Header.Set("x-request-id", "test")
 
 	router := mux.NewRouter()
-	AddDocumentRoutes(log.NewNopLogger(), router, repo, storage.TestBucket)
+	AddDocumentRoutes(log.NewNopLogger(), router, repo, testBucket)
 	router.ServeHTTP(w, req)
 	w.Flush()
 
@@ -195,7 +194,7 @@ func TestDocuments__delete(t *testing.T) {
 	repo := &sqlDocumentRepository{db.DB, log.NewNopLogger()}
 
 	router := mux.NewRouter()
-	AddDocumentRoutes(log.NewNopLogger(), router, repo, storage.TestBucket)
+	AddDocumentRoutes(log.NewNopLogger(), router, repo, testBucket)
 
 	customerID := base.ID()
 	// create document
@@ -233,7 +232,7 @@ func TestDocuments__uploadCustomerDocument(t *testing.T) {
 	req.URL = u // replace query params with invalid values
 
 	router := mux.NewRouter()
-	AddDocumentRoutes(log.NewNopLogger(), router, repo, storage.TestBucket)
+	AddDocumentRoutes(log.NewNopLogger(), router, repo, testBucket)
 	router.ServeHTTP(w, req)
 	w.Flush()
 
diff --git a/pkg/documents/storage/files_test.go b/pkg/customers/files_test.go
similarity index 88%
rename from pkg/documents/storage/files_test.go
rename to pkg/customers/files_test.go
index 3ec349c..4936c99 100644
--- a/pkg/documents/storage/files_test.go
+++ b/pkg/customers/files_test.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by an Apache License
 // license that can be found in the LICENSE file.
 
-package storage
+package customers
 
 import (
 	"context"
@@ -15,6 +15,8 @@ import (
 	"testing"
 	"time"
 
+	"github.com/moov-io/base"
+
 	"github.com/go-kit/kit/log"
 	"github.com/gorilla/mux"
 	"gocloud.dev/blob"
@@ -22,13 +24,13 @@ import (
 
 func TestFiles__proxyLocalFile(t *testing.T) {
 	// first, upload a file
-	bucket, err := TestBucket()
+	bucket, err := testBucket()
 	if err != nil {
 		t.Fatal(err)
 	}
 
-	// customerID, documentID := base.ID(), base.ID()
-	documentKey := "hello" // makeDocumentKey(customerID, documentID)
+	customerID, documentID := base.ID(), base.ID()
+	documentKey := makeDocumentKey(customerID, documentID)
 
 	ctx, cancelFn := context.WithTimeout(context.TODO(), 10*time.Second)
 	defer cancelFn()
@@ -40,7 +42,7 @@ func TestFiles__proxyLocalFile(t *testing.T) {
 	if err != nil {
 		t.Fatal(err)
 	}
-	fd, err := os.Open(filepath.Join("..", "testdata", "colorado.jpg"))
+	fd, err := os.Open(filepath.Join("..", "..", "testdata", "colorado.jpg"))
 	if err != nil {
 		t.Fatal(err)
 	}
diff --git a/pkg/watchman/watchman_test.go b/pkg/customers/watchman_test.go
similarity index 91%
rename from pkg/watchman/watchman_test.go
rename to pkg/customers/watchman_test.go
index 451d0eb..cd581e3 100644
--- a/pkg/watchman/watchman_test.go
+++ b/pkg/customers/watchman_test.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by an Apache License
 // license that can be found in the LICENSE file.
 
-package watchman
+package customers
 
 import (
 	"context"
@@ -20,9 +20,27 @@ import (
 	"github.com/ory/dockertest/v3"
 )
 
+type testWatchmanClient struct {
+	sdn *watchman.OfacSdn
+
+	// error to be returned instead of field from above
+	err error
+}
+
+func (c *testWatchmanClient) Ping() error {
+	return c.err
+}
+
+func (c *testWatchmanClient) Search(_ context.Context, name string, _ string) (*watchman.OfacSdn, error) {
+	if c.err != nil {
+		return nil, c.err
+	}
+	return c.sdn, nil
+}
+
 type watchmanDeployment struct {
 	res    *dockertest.Resource
-	client Client
+	client WatchmanClient
 }
 
 func (d *watchmanDeployment) close(t *testing.T) {
@@ -55,7 +73,7 @@ func spawnWatchman(t *testing.T) *watchmanDeployment {
 		t.Fatal(err)
 	}
 
-	client := NewClient(log.NewNopLogger(), fmt.Sprintf("http://localhost:%s", resource.GetPort("8080/tcp")), false)
+	client := NewWatchmanClient(log.NewNopLogger(), fmt.Sprintf("http://localhost:%s", resource.GetPort("8080/tcp")), false)
 	err = pool.Retry(func() error {
 		return client.Ping()
 	})
@@ -67,7 +85,7 @@ func spawnWatchman(t *testing.T) *watchmanDeployment {
 
 func TestWatchman__client(t *testing.T) {
 	endpoint := ""
-	if client := NewClient(log.NewNopLogger(), endpoint, false); client == nil {
+	if client := NewWatchmanClient(log.NewNopLogger(), endpoint, false); client == nil {
 		t.Fatal("expected non-nil client")
 	}
 
@@ -120,7 +138,7 @@ func TestWatchman__search(t *testing.T) {
 }
 
 func TestWatchman_ping(t *testing.T) {
-	client := &TestWatchmanClient{}
+	client := &testWatchmanClient{}
 
 	// Ping tests
 	if err := client.Ping(); err != nil {
diff --git a/pkg/documents/storage/test_bucket.go b/pkg/documents/storage/test_bucket.go
deleted file mode 100644
index 8d5ca3b..0000000
--- a/pkg/documents/storage/test_bucket.go
+++ /dev/null
@@ -1,25 +0,0 @@
-package storage
-
-import (
-	"context"
-	"fmt"
-	"io/ioutil"
-	"time"
-
-	"gocloud.dev/blob"
-)
-
-var (
-	TestBucket BucketFunc = func() (*blob.Bucket, error) {
-		signer, err := FileblobSigner("http://localhost:8087", "secret")
-		if err != nil {
-			panic(fmt.Sprintf("testBucket: %v", err))
-		}
-
-		ctx, cancelFn := context.WithTimeout(context.TODO(), 1*time.Second)
-		defer cancelFn()
-
-		dir, _ := ioutil.TempDir("", "testBucket")
-		return fileBucket(ctx, dir, signer)
-	}
-)
diff --git a/pkg/watchman/test_watchman.go b/pkg/watchman/test_watchman.go
deleted file mode 100644
index ba01a8f..0000000
--- a/pkg/watchman/test_watchman.go
+++ /dev/null
@@ -1,33 +0,0 @@
-package watchman
-
-import (
-	"context"
-
-	watchman "github.com/moov-io/watchman/client"
-)
-
-type TestWatchmanClient struct {
-	sdn *watchman.OfacSdn
-
-	// error to be returned instead of field from above
-	err error
-}
-
-func NewTestWatchmanClient(sdn *watchman.OfacSdn, err error) *TestWatchmanClient {
-	return &TestWatchmanClient{
-		sdn: sdn,
-		err: err,
-	}
-}
-
-func (c *TestWatchmanClient) Ping() error {
-	return c.err
-}
-
-func (c *TestWatchmanClient) Search(_ context.Context, name string, _ string) (*watchman.OfacSdn, error) {
-	if c.err != nil {
-		return nil, c.err
-	}
-
-	return c.sdn, nil
-}