forked from moul/testman
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_test.go
52 lines (45 loc) · 974 Bytes
/
main_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
package main
import (
"flag"
"os"
"testing"
"github.com/stretchr/testify/require"
)
func TestRun(t *testing.T) {
closer := MustCaptureStdoutAndStderr()
err := run([]string{"testman"})
require.Equal(t, err, flag.ErrHelp)
_ = closer()
}
func ExampleList_examples() {
os.Stderr = os.Stdout // required hack to run the test as an example
os.Chdir("examples")
defer os.Chdir("..")
err := run([]string{"testman", "list", "./..."})
checkErr(err)
// Output:
// github.com/comnoco/testman/v2/examples/testpkg
// TestStableAlwaysSucceed
// TestUnstableMaySucceed
// TestBrokenAlwaysFailing
// ExampleAlwaysSucceed
}
func ExampleList() {
err := run([]string{"testman", "list", "./..."})
if err != nil {
panic(err)
}
// Output:
// github.com/comnoco/testman/v2
// TestRun
// ExampleList_examples
// ExampleList
}
func TestMain(m *testing.M) {
// goleak.VerifyTestMain(m)
}
func checkErr(err error) {
if err != nil {
panic(err)
}
}