Skip to content

Commit

Permalink
Accept sub sub test name for dir
Browse files Browse the repository at this point in the history
  • Loading branch information
nervo committed Aug 8, 2022
1 parent 9788822 commit 6eacdea
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion v2/goldie.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func (g *Goldie) GoldenFileName(t *testing.T, name string) string {
if g.useSubTestNameForDir {
n := strings.Split(t.Name(), "/")
if len(n) > 1 {
dir = filepath.Join(dir, n[1])
dir = filepath.Join(append([]string{dir}, n[1:]...)...)
}
}

Expand Down
7 changes: 7 additions & 0 deletions v2/goldie_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ func TestGoldenFileName(t *testing.T) {
},
expected: fmt.Sprintf("%s/%s/%s%s", defaultFixtureDir, "using_sub_test_name_for_dir", "example", defaultFileNameSuffix),
},
"using sub/sub test name for dir": {
name: "example",
options: []Option{
WithSubTestNameForDir(true),
},
expected: fmt.Sprintf("%s/%s/%s/%s%s", defaultFixtureDir, "using_sub", "sub_test_name_for_dir", "example", defaultFileNameSuffix),
},
}

for name, test := range tests {
Expand Down

0 comments on commit 6eacdea

Please sign in to comment.