Skip to content

Commit ba70f09

Browse files
committed
Fix fixture teardown isolation and output contract checks
1 parent d2cf1f4 commit ba70f09

2 files changed

Lines changed: 14 additions & 7 deletions

File tree

e2e/cli_tests/output_contract_test.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,9 @@ func assertNonJSON(t *testing.T, stdout, flag string) {
4848
if s == "" {
4949
t.Fatalf("--%s: produced empty output", flag)
5050
}
51-
var obj map[string]any
52-
if err := json.Unmarshal([]byte(s), &obj); err == nil {
53-
if _, hasOK := obj["ok"]; hasOK {
54-
t.Fatalf("--%s: output looks like a JSON envelope", flag)
55-
}
51+
var v any
52+
if err := json.Unmarshal([]byte(s), &v); err == nil {
53+
t.Fatalf("--%s: output must not be valid JSON", flag)
5654
}
5755
}
5856

e2e/harness/fixture.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ package harness
33
import (
44
"fmt"
55
"os"
6+
"path/filepath"
67
"strconv"
8+
"strings"
79
"time"
810
)
911

@@ -54,14 +56,18 @@ func NewSharedFixture(cfg *Config) (*SharedFixture, error) {
5456
// Teardown removes all fixture resources. Deleting the board cascades to all
5557
// child resources (cards, columns, comments, steps, reactions).
5658
func (f *SharedFixture) Teardown() error {
59+
var errs []string
5760
if f.BoardID != "" {
5861
r := f.run("board", "delete", f.BoardID)
5962
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)
63+
errs = append(errs, fmt.Sprintf("delete fixture board %s: exit %d\nstderr: %s", f.BoardID, r.ExitCode, r.Stderr))
6164
}
6265
}
6366
if err := os.RemoveAll(f.configHome); err != nil {
64-
return fmt.Errorf("remove fixture config home %s: %w", f.configHome, err)
67+
errs = append(errs, fmt.Sprintf("remove fixture config home %s: %v", f.configHome, err))
68+
}
69+
if len(errs) > 0 {
70+
return fmt.Errorf(strings.Join(errs, "\n"))
6571
}
6672
return nil
6773
}
@@ -143,6 +149,9 @@ func (f *SharedFixture) run(args ...string) *Result {
143149
"FIZZY_PROFILE": f.cfg.Account,
144150
"FIZZY_NO_KEYRING": "1",
145151
"HOME": f.configHome,
152+
"XDG_CONFIG_HOME": filepath.Join(f.configHome, "config"),
153+
"XDG_DATA_HOME": filepath.Join(f.configHome, "data"),
154+
"XDG_STATE_HOME": filepath.Join(f.configHome, "state"),
146155
}
147156
return Execute(f.cfg.BinaryPath, fullArgs, env)
148157
}

0 commit comments

Comments
 (0)