Skip to content

Commit

Permalink
Ensure fresh environment for each test case in formatter tests
Browse files Browse the repository at this point in the history
This commit updates `formatter_test.go` to address an issue where each test case was not receiving a fresh `formatEnvironment`. Previously, a single `formatEnvironment` instance was reused across multiple test cases, leading to potential dependencies on prior tests' states, such as indentation levels, that could result in unintended test failures.
  • Loading branch information
phelrine committed Jan 20, 2024
1 parent 462d74a commit bf00c55
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion internal/formatter/formatter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ func TestFormat(t *testing.T) {
LowerCase: false,
IdentifierQuoted: false,
}
env := &formatEnvironment{}
for _, fname := range files {
b, err := os.ReadFile(fname)
if err != nil {
Expand All @@ -147,6 +146,7 @@ func TestFormat(t *testing.T) {
if err != nil {
t.Fatal(err)
}
env := &formatEnvironment{}
formatted := Eval(parsed, env)
got := strings.TrimRight(formatted.Render(opts), "\n") + "\n"

Expand Down

0 comments on commit bf00c55

Please sign in to comment.