-
Notifications
You must be signed in to change notification settings - Fork 3
/
ginkgo.go
37 lines (27 loc) · 631 Bytes
/
ginkgo.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package goldga
import (
"path/filepath"
"strings"
"github.com/onsi/ginkgo/v2"
)
func getGinkgoPath() string {
spec := ginkgo.CurrentSpecReport()
path := spec.FileName()
if path == "" {
panic("current file name is empty")
}
name := filepath.Base(path)
if ext := filepath.Ext(name); ext != "" {
name = strings.TrimSuffix(name, ext)
name = strings.TrimSuffix(name, "_test")
}
return filepath.Join("testdata", name+".golden")
}
func getGinkgoTestName() string {
spec := ginkgo.CurrentSpecReport()
testName := spec.FullText()
if testName == "" {
panic("current test name is empty")
}
return testName
}