Skip to content

Commit b38e838

Browse files
add tests
1 parent e5ebd84 commit b38e838

File tree

5 files changed

+404
-0
lines changed

5 files changed

+404
-0
lines changed

tests/failed_test.go

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package parsetest
2+
3+
import (
4+
"bytes"
5+
"os"
6+
"path/filepath"
7+
"testing"
8+
9+
"github.com/stretchr/testify/assert"
10+
"github.com/stretchr/testify/require"
11+
12+
"github.com/mfridman/tparse/internal/app"
13+
"github.com/mfridman/tparse/parse"
14+
)
15+
16+
func TestFailedTestsTable(t *testing.T) {
17+
t.Parallel()
18+
19+
base := filepath.Join("testdata", "failed")
20+
21+
tt := []struct {
22+
fileName string
23+
exitCode int
24+
}{
25+
{"test_01", 1},
26+
{"test_02", 1},
27+
{"test_03", 1},
28+
{"test_04", 1},
29+
}
30+
31+
for _, tc := range tt {
32+
t.Run(tc.fileName, func(t *testing.T) {
33+
buf := bytes.NewBuffer(nil)
34+
inputFile := filepath.Join(base, tc.fileName+".jsonl")
35+
options := app.Options{
36+
FileName: inputFile,
37+
Output: buf,
38+
Sorter: parse.SortByPackageName,
39+
TestTableOptions: app.TestTableOptions{
40+
Pass: true, // Enable test table output
41+
Skip: true, // Also show skipped tests
42+
},
43+
}
44+
gotExitCode, err := app.Run(options)
45+
require.NoError(t, err)
46+
assert.Equal(t, tc.exitCode, gotExitCode)
47+
48+
goldenFile := filepath.Join(base, tc.fileName+".golden")
49+
want, err := os.ReadFile(goldenFile)
50+
if err != nil {
51+
t.Fatal(err)
52+
}
53+
checkGolden(t, inputFile, goldenFile, buf.Bytes(), want)
54+
})
55+
}
56+
}
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
╭────────┬─────────┬───────────────────────────────────────┬───────────────────────────────────────╮
2+
│ Status │ Elapsed │ Test │ Package │
3+
├────────┼─────────┼───────────────────────────────────────┼───────────────────────────────────────┤
4+
│ PASS │ 5.45 │ TestMigrateUpWithReset │ github.com/pressly/goose/v3/tests/e2e │
5+
│ PASS │ 5.39 │ TestMigrateUpTo │ github.com/pressly/goose/v3/tests/e2e │
6+
│ PASS │ 4.96 │ TestMigrateUpByOne │ github.com/pressly/goose/v3/tests/e2e │
7+
│ PASS │ 3.37 │ TestMigrateFull │ github.com/pressly/goose/v3/tests/e2e │
8+
│ PASS │ 2.53 │ TestMigrateUpWithRedo │ github.com/pressly/goose/v3/tests/e2e │
9+
│ PASS │ 2.32 │ TestNoVersioning │ github.com/pressly/goose/v3/tests/e2e │
10+
│ PASS │ 0.02 │ TestNoVersioning/seed-up-down-to-zero │ github.com/pressly/goose/v3/tests/e2e │
11+
│ PASS │ 0.02 │ TestNoVersioning/test-seed-up-reset │ github.com/pressly/goose/v3/tests/e2e │
12+
│ PASS │ 0.01 │ TestNoVersioning/test-seed-up-redo │ github.com/pressly/goose/v3/tests/e2e │
13+
│ FAIL │ 3.71 │ TestNotAllowMissing │ github.com/pressly/goose/v3/tests/e2e │
14+
│ FAIL │ 2.55 │ TestAllowMissingUpWithRedo │ github.com/pressly/goose/v3/tests/e2e │
15+
│ FAIL │ 3.16 │ TestNowAllowMissingUpByOne │ github.com/pressly/goose/v3/tests/e2e │
16+
│ FAIL │ 4.13 │ TestAllowMissingUpWithReset │ github.com/pressly/goose/v3/tests/e2e │
17+
│ FAIL │ 3.15 │ TestAllowMissingUpByOne │ github.com/pressly/goose/v3/tests/e2e │
18+
│ FAIL │ 5.11 │ TestMigrateAllowMissingDown │ github.com/pressly/goose/v3/tests/e2e │
19+
╰────────┴─────────┴───────────────────────────────────────┴───────────────────────────────────────╯
20+
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
21+
┃ FAIL package: github.com/pressly/goose/v3/tests/e2e ┃
22+
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
23+
24+
--- FAIL: TestAllowMissingUpByOne (3.15s)
25+
26+
allow_missing_test.go:329: unexpected number value: got:0 want:1
27+
2022/05/19 22:03:07 OK 00001_a.sql
28+
2022/05/19 22:03:07 OK 00002_b.sql
29+
2022/05/19 22:03:07 OK 00003_c.sql
30+
2022/05/19 22:03:07 OK 00004_d.sql
31+
2022/05/19 22:03:07 OK 00005_e.sql
32+
2022/05/19 22:03:07 OK 00006_f.sql
33+
2022/05/19 22:03:07 OK 00007_g.sql
34+
2022/05/19 22:03:07 OK 00008_h.sql
35+
2022/05/19 22:03:07 OK 00009_i.sql
36+
2022/05/19 22:03:07 OK 00010_j.sql
37+
2022/05/19 22:03:07 OK 00011_k.sql
38+
2022/05/19 22:03:07 goose: no migrations to run. current version: 11
39+
2022/05/19 22:03:07 OK 00011_k.sql
40+
2022/05/19 22:03:07 OK 00010_j.sql
41+
42+
────────────────────────────────────────────────────────────────────────────────────────────────
43+

44+
--- FAIL: TestAllowMissingUpWithRedo (2.55s)
45+
46+
allow_missing_test.go:329: unexpected number value: got:0 want:1
47+
48+
────────────────────────────────────────────────────────────────────────────────────────────────
49+

50+
--- FAIL: TestAllowMissingUpWithReset (4.13s)
51+
52+
allow_missing_test.go:329: unexpected number value: got:0 want:1
53+
2022/05/19 22:03:08 OK 00001_a.sql
54+
2022/05/19 22:03:08 OK 00002_b.sql
55+
2022/05/19 22:03:08 OK 00003_c.sql
56+
2022/05/19 22:03:08 OK 00004_d.sql
57+
2022/05/19 22:03:08 OK 00005_e.sql
58+
2022/05/19 22:03:08 OK 00006_f.sql
59+
2022/05/19 22:03:08 OK 00007_g.sql
60+
2022/05/19 22:03:08 OK 00008_h.sql
61+
2022/05/19 22:03:08 OK 00009_i.sql
62+
2022/05/19 22:03:08 OK 00010_j.sql
63+
2022/05/19 22:03:08 OK 00011_k.sql
64+
2022/05/19 22:03:08 goose: no migrations to run. current version: 11
65+
66+
────────────────────────────────────────────────────────────────────────────────────────────────
67+

68+
--- FAIL: TestMigrateAllowMissingDown (5.11s)
69+
70+
allow_missing_test.go:329: unexpected number value: got:0 want:1
71+
2022/05/19 22:03:09 OK 00005_e.sql
72+
2022/05/19 22:03:09 OK 00006_f.sql
73+
2022/05/19 22:03:09 OK 00007_g.sql
74+
2022/05/19 22:03:09 OK 00008_h.sql
75+
2022/05/19 22:03:09 OK 00009_i.sql
76+
2022/05/19 22:03:09 OK 00010_j.sql
77+
2022/05/19 22:03:09 OK 00001_a.sql
78+
2022/05/19 22:03:09 OK 00001_a.sql
79+
2022/05/19 22:03:09 OK 00011_k.sql
80+
2022/05/19 22:03:09 goose: no migrations to run. current version: 11
81+
2022/05/19 22:03:09 OK 00001_a.sql
82+
2022/05/19 22:03:09 OK 00011_k.sql
83+
2022/05/19 22:03:09 OK 00002_b.sql
84+
2022/05/19 22:03:09 OK 00010_j.sql
85+
2022/05/19 22:03:09 OK 00009_i.sql
86+
2022/05/19 22:03:09 OK 00002_b.sql
87+
2022/05/19 22:03:09 OK 00008_h.sql
88+
2022/05/19 22:03:09 OK 00001_a.sql
89+
2022/05/19 22:03:09 OK 00002_b.sql
90+
2022/05/19 22:03:09 OK 00003_c.sql
91+
2022/05/19 22:03:09 OK 00007_g.sql
92+
2022/05/19 22:03:09 OK 00002_b.sql
93+
2022/05/19 22:03:09 goose: no migrations to run. current version: 2
94+
2022/05/19 22:03:09 OK 00006_f.sql
95+
2022/05/19 22:03:09 OK 00003_c.sql
96+
2022/05/19 22:03:09 OK 00005_e.sql
97+
2022/05/19 22:03:09 OK 00003_c.sql
98+
2022/05/19 22:03:09 OK 00004_d.sql
99+
2022/05/19 22:03:09 OK 00004_d.sql
100+
2022/05/19 22:03:09 OK 00003_c.sql
101+
2022/05/19 22:03:09 OK 00004_d.sql
102+
2022/05/19 22:03:09 OK 00002_b.sql
103+
2022/05/19 22:03:09 OK 00004_d.sql
104+
2022/05/19 22:03:09 OK 00001_a.sql
105+
2022/05/19 22:03:09 OK 00005_e.sql
106+
2022/05/19 22:03:09 OK 00005_e.sql
107+
2022/05/19 22:03:09 OK 00005_e.sql
108+
2022/05/19 22:03:09 OK 00006_f.sql
109+
2022/05/19 22:03:09 OK 00006_f.sql
110+
2022/05/19 22:03:09 OK 00006_f.sql
111+
2022/05/19 22:03:09 OK 00007_g.sql
112+
2022/05/19 22:03:09 OK 00007_g.sql
113+
2022/05/19 22:03:09 OK 00007_g.sql
114+
2022/05/19 22:03:09 OK 00008_h.sql
115+
116+
────────────────────────────────────────────────────────────────────────────────────────────────
117+

118+
--- FAIL: TestNotAllowMissing (3.71s)
119+
120+
allow_missing_test.go:329: unexpected number value: got:0 want:1
121+
122+
────────────────────────────────────────────────────────────────────────────────────────────────
123+

124+
--- FAIL: TestNowAllowMissingUpByOne (3.16s)
125+
126+
allow_missing_test.go:329: unexpected number value: got:0 want:1
127+
128+
╭────────┬─────────┬───────────────────────────────────────┬───────┬──────┬──────┬──────╮
129+
│ Status │ Elapsed │ Package │ Cover │ Pass │ Fail │ Skip │
130+
├────────┼─────────┼───────────────────────────────────────┼───────┼──────┼──────┼──────┤
131+
│ FAIL │ 9.00s │ github.com/pressly/goose/v3/tests/e2e │ -- │ 9 │ 6 │ 0 │
132+
╰────────┴─────────┴───────────────────────────────────────┴───────┴──────┴──────┴──────╯
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
╭────────┬─────────┬──────────────┬──────────────────────────────────────╮
2+
│ Status │ Elapsed │ Test │ Package │
3+
├────────┼─────────┼──────────────┼──────────────────────────────────────┤
4+
│ FAIL │ 1.00 │ TestWhatever │ github.com/mfridman/debug-go/testing │
5+
╰────────┴─────────┴──────────────┴──────────────────────────────────────╯
6+
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
7+
┃ FAIL package: github.com/mfridman/debug-go/testing ┃
8+
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
9+
10+
--- FAIL: TestWhatever (1.00s)
11+
12+
main_test.go:13: assert error
13+
main_test.go:14:
14+
Error Trace: main_test.go:14
15+
Error: "does not contain" does not contain "ostriche"
16+
Test: TestWhatever
17+
main_test.go:15:
18+
Error Trace: main_test.go:15
19+
Error: Received unexpected error:
20+
make the errorss..
21+
Test: TestWhatever
22+
main_test.go:17: skdhjfg
23+
24+
╭────────┬─────────┬──────────────────────────────────────┬───────┬──────┬──────┬──────╮
25+
│ Status │ Elapsed │ Package │ Cover │ Pass │ Fail │ Skip │
26+
├────────┼─────────┼──────────────────────────────────────┼───────┼──────┼──────┼──────┤
27+
│ FAIL │ 1.11s │ github.com/mfridman/debug-go/testing │ -- │ 0 │ 1 │ 0 │
28+
╰────────┴─────────┴──────────────────────────────────────┴───────┴──────┴──────┴──────╯

0 commit comments

Comments
 (0)