Skip to content

Commit 724daca

Browse files
committed
Address PR review feedback on e2e harness
1 parent c6ea62b commit 724daca

5 files changed

Lines changed: 22 additions & 15 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,6 @@ completions/
3232
# Profiling
3333
profiles/
3434
default.pgo
35+
36+
# Local test credentials
37+
.env.test

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55

66
BINARY := $(CURDIR)/bin/fizzy
77

8-
# Load local test credentials if present (file is git-excluded via .git/info/exclude).
8+
# Load local test credentials if present, but refuse tracked local secret files.
9+
ifneq ($(shell git ls-files --error-unmatch .env.test >/dev/null 2>&1 && echo tracked),)
10+
$(error .env.test is tracked by Git. Remove it from version control and keep local secret files untracked)
11+
endif
912
-include .env.test
1013
export FIZZY_TEST_TOKEN FIZZY_TEST_ACCOUNT FIZZY_TEST_API_URL
1114
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)

e2e/cli_tests/helpers_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -306,14 +306,14 @@ func avatarRedirects(t *testing.T, avatarURL string) bool {
306306
t.Fatalf("fetch avatar headers: %v", err)
307307
}
308308
resp.Body.Close()
309-
switch resp.StatusCode {
310-
case http.StatusFound:
311-
return true
312-
case http.StatusOK:
309+
switch {
310+
case resp.StatusCode == http.StatusOK:
313311
return false
312+
case resp.StatusCode/100 == 3:
313+
return true
314314
}
315315
time.Sleep(200 * time.Millisecond)
316316
}
317-
t.Fatalf("avatar endpoint %s did not settle on 200 or 302", avatarURL)
317+
t.Fatalf("avatar endpoint %s did not settle on 200 or 3xx", avatarURL)
318318
return false
319319
}

e2e/cli_tests/search_and_auth_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ func TestAuthInvalidToken(t *testing.T) {
1717
badCfg := *cfg
1818
badCfg.Token = "fizzy_invalid_token"
1919
h := harness.NewWithConfig(t, &badCfg)
20-
assertResult(t, h.Run("board", "list"), harness.ExitAuth)
20+
assertResult(t, h.Run("board", "list"), harness.ExitAuthFailure)
2121
}
2222

2323
func TestAuthMissingToken(t *testing.T) {
2424
missingCfg := *cfg
2525
missingCfg.Token = ""
2626
h := harness.NewWithConfig(t, &missingCfg)
27-
assertResult(t, h.Run("board", "list"), harness.ExitAuth)
27+
assertResult(t, h.Run("board", "list"), harness.ExitAuthFailure)
2828
}

e2e/harness/fixture.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,14 @@ func NewSharedFixture(cfg *Config) (*SharedFixture, error) {
5151
// Teardown removes all fixture resources. Deleting the board cascades to all
5252
// child resources (cards, columns, comments, steps, reactions).
5353
func (f *SharedFixture) Teardown() error {
54-
defer os.RemoveAll(f.configHome)
55-
if f.BoardID == "" {
56-
return nil
57-
}
58-
r := f.run("board", "delete", f.BoardID)
59-
if r.ExitCode != ExitSuccess && r.ExitCode != ExitNotFound {
60-
return fmt.Errorf("delete fixture board %s: exit %d\nstderr: %s", f.BoardID, r.ExitCode, r.Stderr)
54+
if f.BoardID != "" {
55+
r := f.run("board", "delete", f.BoardID)
56+
if r.ExitCode != ExitSuccess && r.ExitCode != ExitNotFound {
57+
return fmt.Errorf("delete fixture board %s: exit %d\nstderr: %s", f.BoardID, r.ExitCode, r.Stderr)
58+
}
59+
}
60+
if err := os.RemoveAll(f.configHome); err != nil {
61+
return fmt.Errorf("remove fixture config home %s: %w", f.configHome, err)
6162
}
6263
return nil
6364
}

0 commit comments

Comments
 (0)