-
-
Notifications
You must be signed in to change notification settings - Fork 58
/
Copy pathis-1.7_test.go
54 lines (48 loc) · 1016 Bytes
/
is-1.7_test.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//go:build go1.7
// +build go1.7
package is
import (
"bytes"
"strings"
"testing"
)
// TestSubtests ensures subtests work as expected.
// https://github.com/matryer/is/issues/1
func TestSubtests(t *testing.T) {
t.Run("sub1", func(t *testing.T) {
is := New(t)
is.Equal(1+1, 2)
})
}
func TestHelper(t *testing.T) {
tests := []struct {
name string
helper bool
expectedFilename string
}{
{
name: "without helper",
helper: false,
expectedFilename: "is_helper_test.go",
},
{
name: "with helper",
helper: true,
expectedFilename: "is-1.7_test.go",
},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
tt := &mockT{}
is := NewRelaxed(tt)
var buf bytes.Buffer
is.out = &buf
helper(is, tc.helper)
actual := buf.String()
t.Log(actual)
if !strings.Contains(actual, tc.expectedFilename) {
t.Errorf("string does not contain correct filename: %s", actual)
}
})
}
}