-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsnapshot_test.go
More file actions
50 lines (39 loc) · 1.07 KB
/
snapshot_test.go
File metadata and controls
50 lines (39 loc) · 1.07 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"maps"
"slices"
"testing"
"github.com/stretchr/testify/require"
)
func TestParseFileSnapshotRejectsLowercaseSuffixes(t *testing.T) {
t.Parallel()
snapshot, err := parseFileSnapshot([]byte(`package sample
import "testing"
func TestAlpha(t *testing.T) {}
func Testify(t *testing.T) {}
func FuzzAlpha(f *testing.F) {}
func Fuzzbar(f *testing.F) {}
func Example() {}
func ExampleFoo() {}
func Examplefoo() {}
`))
require.NoError(t, err)
require.Equal(t, []string{"Example", "ExampleFoo", "FuzzAlpha", "TestAlpha"}, slices.Sorted(maps.Keys(snapshot.tests)))
}
func TestParseFileSnapshotRecordsRunnableTests(t *testing.T) {
t.Parallel()
snapshot, err := parseFileSnapshot([]byte(`package sample
import . "testing"
const answer = 42
var packageValue = answer
type fixture struct{}
func helper() {}
func init() {}
func TestMain(m *M) {}
func TestAlpha(t *T) {}
func FuzzAlpha(f *F) {}
`))
require.NoError(t, err)
require.Equal(t, "sample", snapshot.packageName)
require.Equal(t, []string{"FuzzAlpha", "TestAlpha"}, slices.Sorted(maps.Keys(snapshot.tests)))
}