diff --git a/v2/goldie.go b/v2/goldie.go index 78e3f27..af0df23 100644 --- a/v2/goldie.go +++ b/v2/goldie.go @@ -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:]...)...) } } diff --git a/v2/goldie_test.go b/v2/goldie_test.go index 599dfb3..833c96d 100644 --- a/v2/goldie_test.go +++ b/v2/goldie_test.go @@ -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 {