Skip to content

Commit

Permalink
feat: refine deterministic order test
Browse files Browse the repository at this point in the history
Signed-off-by: Brian McGee <[email protected]>
  • Loading branch information
brianmcgee committed Oct 21, 2024
1 parent 9d53c96 commit 66bdc82
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1564,18 +1564,11 @@ func TestStdin(t *testing.T) {
func TestDeterministicOrderingInPipeline(t *testing.T) {
as := require.New(t)

// capture current cwd, so we can replace it after the test is finished
cwd, err := os.Getwd()
as.NoError(err)

t.Cleanup(func() {
// return to the previous working directory
as.NoError(os.Chdir(cwd))
})

tempDir := test.TempExamples(t)
configPath := tempDir + "/treefmt.toml"

test.ChangeWorkDir(t, tempDir)

test.WriteConfig(t, configPath, &config.Config{
FormatterConfigs: map[string]*config.Formatter{
// a and b have no priority set, which means they default to 0 and should execute first
Expand All @@ -1600,8 +1593,7 @@ func TestDeterministicOrderingInPipeline(t *testing.T) {
},
})

_, err = treefmt(t, "-C", tempDir)
as.NoError(err)
treefmt2(t, withNoError(t))

matcher := regexp.MustCompile("^fmt-(.*)")

Expand Down

0 comments on commit 66bdc82

Please sign in to comment.