diff --git a/abcconfig/config_test.go b/abcconfig/config_test.go index d73bded..241ed80 100644 --- a/abcconfig/config_test.go +++ b/abcconfig/config_test.go @@ -136,9 +136,6 @@ func TestBindLoadEnv(t *testing.T) { t.Error(err) } - if cfg.DB.DB != "postgres" { - t.Errorf("expected postgres, got %s", cfg.DB.DB) - } if cfg.DB.DBName != "lolwtf_test" { t.Errorf("expected lolwtf_test, got %s", cfg.DB.DBName) } @@ -239,9 +236,6 @@ func TestBindPublicPathEnv(t *testing.T) { t.Error(err) } - if cfg.DB.DB != "postgres" { - t.Errorf("expected postgres, got %s", cfg.DB.DB) - } if cfg.DB.DBName != "lolwtf_dev" { t.Errorf("expected lolwtf_dev, got %s", cfg.DB.DBName) } @@ -375,9 +369,6 @@ func TestBind(t *testing.T) { if cfg.Env != "cool" { t.Errorf("expected env to be cool, got %s", cfg.Env) } - if cfg.DB.DB != "postgres" { - t.Errorf("expected postgres, got %s", cfg.DB.DB) - } if cfg.DB.Port != 5432 { t.Errorf("expected port 5432, got %d", cfg.DB.Port) } @@ -628,7 +619,6 @@ func TestGetTagMappings(t *testing.T) { {chain: "server.render-recompile", env: "SERVER_RENDER_RECOMPILE"}, {chain: "server.sessions-dev-storer", env: "SERVER_SESSIONS_DEV_STORER"}, {chain: "server.public-path", env: "SERVER_PUBLIC_PATH"}, - {chain: "db.db", env: "DB_DB"}, {chain: "db.dbname", env: "DB_DBNAME"}, {chain: "db.host", env: "DB_HOST"}, {chain: "db.port", env: "DB_PORT"}, diff --git a/abcdatabase/database_test.go b/abcdatabase/database_test.go index b6bef38..a3575dc 100644 --- a/abcdatabase/database_test.go +++ b/abcdatabase/database_test.go @@ -14,12 +14,6 @@ func TestGetConnStr(t *testing.T) { cfg := abcconfig.DBConfig{} - _, err := GetConnStr(cfg) - if err == nil { - t.Error("expected error") - } - - cfg.DB = "postgres" cfg.User = "a" cfg.Pass = "b" cfg.DBName = "c" diff --git a/abcmiddleware/errors_test.go b/abcmiddleware/errors_test.go index b3fe28d..ce4cb70 100644 --- a/abcmiddleware/errors_test.go +++ b/abcmiddleware/errors_test.go @@ -98,7 +98,7 @@ func TestCustomErrorHandler(t *testing.T) { }) w = httptest.NewRecorder() r = httptest.NewRequest("get", "/", nil) - r = r.WithContext(context.WithValue(context.Background(), CtxLoggerKey, zap.NewNop())) + r = r.WithContext(context.WithValue(context.Background(), CTXKeyLogger, zap.NewNop())) fn.ServeHTTP(w, r) if rndr.status != http.StatusInternalServerError { t.Errorf("expected StatusInternalServerError, got %d", rndr.status) @@ -119,7 +119,7 @@ func TestCustomErrorHandler(t *testing.T) { }) w = httptest.NewRecorder() r = httptest.NewRequest("get", "/", nil) - r = r.WithContext(context.WithValue(context.Background(), CtxLoggerKey, zap.NewNop())) + r = r.WithContext(context.WithValue(context.Background(), CTXKeyLogger, zap.NewNop())) fn.ServeHTTP(w, r) if rndr.status != 100 { t.Errorf("expected 100, got %d", rndr.status) diff --git a/abcmiddleware/log_test.go b/abcmiddleware/log_test.go index 8851dad..ae943b3 100644 --- a/abcmiddleware/log_test.go +++ b/abcmiddleware/log_test.go @@ -17,11 +17,11 @@ func TestLog(t *testing.T) { t.Error(err) } - ctx = context.WithValue(ctx, CtxLoggerKey, z) + ctx = context.WithValue(ctx, CTXKeyLogger, z) r := &http.Request{} r = r.WithContext(ctx) // Ensure log can be called successfully. Ignore response because we don't // need to validate anything. - _ = Log(r) + _ = Logger(r) } diff --git a/abcmiddleware/request_id_test.go b/abcmiddleware/request_id_test.go index a6cd720..3264e71 100644 --- a/abcmiddleware/request_id_test.go +++ b/abcmiddleware/request_id_test.go @@ -14,6 +14,12 @@ import ( "go.uber.org/zap" ) +type bufSyncer struct { + *bytes.Buffer +} + +func (bufSyncer) Sync() error { return nil } + func TestRequestID(t *testing.T) { t.Parallel() diff --git a/abcserver/routes_test.go b/abcserver/routes_test.go index df7272d..8a39686 100644 --- a/abcserver/routes_test.go +++ b/abcserver/routes_test.go @@ -122,7 +122,7 @@ func TestNotFound(t *testing.T) { notFound := n.Handler(serverCfg, render) // set the logger on the context so calls to abcmiddleware.Log don't fail - r = r.WithContext(context.WithValue(r.Context(), abcmiddleware.CtxLoggerKey, log)) + r = r.WithContext(context.WithValue(r.Context(), abcmiddleware.CTXKeyLogger, log)) // Call the handler notFound(w, r) @@ -140,7 +140,7 @@ func TestNotFound(t *testing.T) { w = httptest.NewRecorder() // set the logger on the context so calls to abcmiddleware.Log don't fail - r = r.WithContext(context.WithValue(r.Context(), abcmiddleware.CtxLoggerKey, log)) + r = r.WithContext(context.WithValue(r.Context(), abcmiddleware.CTXKeyLogger, log)) // Call the handler notFound(w, r) @@ -157,7 +157,7 @@ func TestNotFound(t *testing.T) { r = httptest.NewRequest("GET", "/assets/css/main-manifestmagic.css", nil) w = httptest.NewRecorder() - r = r.WithContext(context.WithValue(r.Context(), abcmiddleware.CtxLoggerKey, log)) + r = r.WithContext(context.WithValue(r.Context(), abcmiddleware.CTXKeyLogger, log)) // Set asset manifest to test manifest hotpath manifest := map[string]string{ diff --git a/cmd/new_test.go b/cmd/new_test.go index 6497f27..c82c135 100644 --- a/cmd/new_test.go +++ b/cmd/new_test.go @@ -18,17 +18,17 @@ func TestGetAppPath(t *testing.T) { gopath := os.Getenv("GOPATH") os.Setenv("GOPATH", "testpath/test") - appPath, importPath, appName, appEnvName, err := getAppPath([]string{"."}) + appPath, _, importPath, appName, appEnvName, err := getAppPath([]string{".", "/templatepath"}) if err == nil { t.Errorf("expected error, but got none: %s - %s", appPath, appName) } - appPath, importPath, appName, appEnvName, err = getAppPath([]string{"/"}) + appPath, _, importPath, appName, appEnvName, err = getAppPath([]string{"/", "/templatepath"}) if err == nil { t.Errorf("expected error, but got none: %s - %s", appPath, appName) } - appPath, importPath, appName, appEnvName, err = getAppPath([]string{"/test"}) + appPath, _, importPath, appName, appEnvName, err = getAppPath([]string{"/test", "/templatepath"}) if err != nil { t.Error(err) } @@ -45,7 +45,7 @@ func TestGetAppPath(t *testing.T) { t.Errorf("mismatch, got %s", importPath) } - appPath, importPath, appName, appEnvName, err = getAppPath([]string{"./stuff/test"}) + appPath, _, importPath, appName, appEnvName, err = getAppPath([]string{"./stuff/test"}, "/templatepath") if err != nil { t.Error(err) } @@ -279,7 +279,7 @@ func TestNewCmdWalk(t *testing.T) { } // check template file write - err = afero.WriteFile(appFS, "/templates/template.go.tmpl", []byte(`package {{.AppName}}`), 0644) + err = afero.WriteFile(appFS, "/templates/template.go.tmpl", []byte(`package {{.AppName}}`), 0644) if err != nil { t.Fatal(err) }