Skip to content

Commit 7376b8c

Browse files
committed
fix broken tests
1 parent 460a150 commit 7376b8c

File tree

7 files changed

+18
-28
lines changed

7 files changed

+18
-28
lines changed

abcconfig/config_test.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,6 @@ func TestBindLoadEnv(t *testing.T) {
136136
t.Error(err)
137137
}
138138

139-
if cfg.DB.DB != "postgres" {
140-
t.Errorf("expected postgres, got %s", cfg.DB.DB)
141-
}
142139
if cfg.DB.DBName != "lolwtf_test" {
143140
t.Errorf("expected lolwtf_test, got %s", cfg.DB.DBName)
144141
}
@@ -239,9 +236,6 @@ func TestBindPublicPathEnv(t *testing.T) {
239236
t.Error(err)
240237
}
241238

242-
if cfg.DB.DB != "postgres" {
243-
t.Errorf("expected postgres, got %s", cfg.DB.DB)
244-
}
245239
if cfg.DB.DBName != "lolwtf_dev" {
246240
t.Errorf("expected lolwtf_dev, got %s", cfg.DB.DBName)
247241
}
@@ -375,9 +369,6 @@ func TestBind(t *testing.T) {
375369
if cfg.Env != "cool" {
376370
t.Errorf("expected env to be cool, got %s", cfg.Env)
377371
}
378-
if cfg.DB.DB != "postgres" {
379-
t.Errorf("expected postgres, got %s", cfg.DB.DB)
380-
}
381372
if cfg.DB.Port != 5432 {
382373
t.Errorf("expected port 5432, got %d", cfg.DB.Port)
383374
}
@@ -628,7 +619,6 @@ func TestGetTagMappings(t *testing.T) {
628619
{chain: "server.render-recompile", env: "SERVER_RENDER_RECOMPILE"},
629620
{chain: "server.sessions-dev-storer", env: "SERVER_SESSIONS_DEV_STORER"},
630621
{chain: "server.public-path", env: "SERVER_PUBLIC_PATH"},
631-
{chain: "db.db", env: "DB_DB"},
632622
{chain: "db.dbname", env: "DB_DBNAME"},
633623
{chain: "db.host", env: "DB_HOST"},
634624
{chain: "db.port", env: "DB_PORT"},

abcdatabase/database_test.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ func TestGetConnStr(t *testing.T) {
1414

1515
cfg := abcconfig.DBConfig{}
1616

17-
_, err := GetConnStr(cfg)
18-
if err == nil {
19-
t.Error("expected error")
20-
}
21-
22-
cfg.DB = "postgres"
2317
cfg.User = "a"
2418
cfg.Pass = "b"
2519
cfg.DBName = "c"

abcmiddleware/errors_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func TestCustomErrorHandler(t *testing.T) {
9898
})
9999
w = httptest.NewRecorder()
100100
r = httptest.NewRequest("get", "/", nil)
101-
r = r.WithContext(context.WithValue(context.Background(), CtxLoggerKey, zap.NewNop()))
101+
r = r.WithContext(context.WithValue(context.Background(), CTXKeyLogger, zap.NewNop()))
102102
fn.ServeHTTP(w, r)
103103
if rndr.status != http.StatusInternalServerError {
104104
t.Errorf("expected StatusInternalServerError, got %d", rndr.status)
@@ -119,7 +119,7 @@ func TestCustomErrorHandler(t *testing.T) {
119119
})
120120
w = httptest.NewRecorder()
121121
r = httptest.NewRequest("get", "/", nil)
122-
r = r.WithContext(context.WithValue(context.Background(), CtxLoggerKey, zap.NewNop()))
122+
r = r.WithContext(context.WithValue(context.Background(), CTXKeyLogger, zap.NewNop()))
123123
fn.ServeHTTP(w, r)
124124
if rndr.status != 100 {
125125
t.Errorf("expected 100, got %d", rndr.status)

abcmiddleware/log_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ func TestLog(t *testing.T) {
1717
t.Error(err)
1818
}
1919

20-
ctx = context.WithValue(ctx, CtxLoggerKey, z)
20+
ctx = context.WithValue(ctx, CTXKeyLogger, z)
2121
r := &http.Request{}
2222
r = r.WithContext(ctx)
2323

2424
// Ensure log can be called successfully. Ignore response because we don't
2525
// need to validate anything.
26-
_ = Log(r)
26+
_ = Logger(r)
2727
}

abcmiddleware/request_id_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ import (
1414
"go.uber.org/zap"
1515
)
1616

17+
type bufSyncer struct {
18+
*bytes.Buffer
19+
}
20+
21+
func (bufSyncer) Sync() error { return nil }
22+
1723
func TestRequestID(t *testing.T) {
1824
t.Parallel()
1925

abcserver/routes_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func TestNotFound(t *testing.T) {
122122
notFound := n.Handler(serverCfg, render)
123123

124124
// set the logger on the context so calls to abcmiddleware.Log don't fail
125-
r = r.WithContext(context.WithValue(r.Context(), abcmiddleware.CtxLoggerKey, log))
125+
r = r.WithContext(context.WithValue(r.Context(), abcmiddleware.CTXKeyLogger, log))
126126

127127
// Call the handler
128128
notFound(w, r)
@@ -140,7 +140,7 @@ func TestNotFound(t *testing.T) {
140140
w = httptest.NewRecorder()
141141

142142
// set the logger on the context so calls to abcmiddleware.Log don't fail
143-
r = r.WithContext(context.WithValue(r.Context(), abcmiddleware.CtxLoggerKey, log))
143+
r = r.WithContext(context.WithValue(r.Context(), abcmiddleware.CTXKeyLogger, log))
144144

145145
// Call the handler
146146
notFound(w, r)
@@ -157,7 +157,7 @@ func TestNotFound(t *testing.T) {
157157
r = httptest.NewRequest("GET", "/assets/css/main-manifestmagic.css", nil)
158158
w = httptest.NewRecorder()
159159

160-
r = r.WithContext(context.WithValue(r.Context(), abcmiddleware.CtxLoggerKey, log))
160+
r = r.WithContext(context.WithValue(r.Context(), abcmiddleware.CTXKeyLogger, log))
161161

162162
// Set asset manifest to test manifest hotpath
163163
manifest := map[string]string{

cmd/new_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@ func TestGetAppPath(t *testing.T) {
1818
gopath := os.Getenv("GOPATH")
1919
os.Setenv("GOPATH", "testpath/test")
2020

21-
appPath, importPath, appName, appEnvName, err := getAppPath([]string{"."})
21+
appPath, _, importPath, appName, appEnvName, err := getAppPath([]string{".", "/templatepath"})
2222
if err == nil {
2323
t.Errorf("expected error, but got none: %s - %s", appPath, appName)
2424
}
2525

26-
appPath, importPath, appName, appEnvName, err = getAppPath([]string{"/"})
26+
appPath, _, importPath, appName, appEnvName, err = getAppPath([]string{"/", "/templatepath"})
2727
if err == nil {
2828
t.Errorf("expected error, but got none: %s - %s", appPath, appName)
2929
}
3030

31-
appPath, importPath, appName, appEnvName, err = getAppPath([]string{"/test"})
31+
appPath, _, importPath, appName, appEnvName, err = getAppPath([]string{"/test", "/templatepath"})
3232
if err != nil {
3333
t.Error(err)
3434
}
@@ -45,7 +45,7 @@ func TestGetAppPath(t *testing.T) {
4545
t.Errorf("mismatch, got %s", importPath)
4646
}
4747

48-
appPath, importPath, appName, appEnvName, err = getAppPath([]string{"./stuff/test"})
48+
appPath, _, importPath, appName, appEnvName, err = getAppPath([]string{"./stuff/test"}, "/templatepath")
4949
if err != nil {
5050
t.Error(err)
5151
}
@@ -279,7 +279,7 @@ func TestNewCmdWalk(t *testing.T) {
279279
}
280280

281281
// check template file write
282-
err = afero.WriteFile(appFS, "/templates/template.go.tmpl", []byte(`package {{.AppName}}`), 0644)
282+
err = afero.WriteFile(appFS, "/templates/template.go.tmpl", []byte(`package {{.AppName}}`), 0644)
283283
if err != nil {
284284
t.Fatal(err)
285285
}

0 commit comments

Comments
 (0)