-
Notifications
You must be signed in to change notification settings - Fork 1
/
catwalk.go
38 lines (32 loc) · 1 KB
/
catwalk.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
package catwalk
import (
"testing"
tea "github.com/charmbracelet/bubbletea"
"github.com/cockroachdb/datadriven"
)
// RunModel runs the tests contained in the file pointed to by 'path'
// on the model m, using a fresh driver initialize via NewDriver and
// the specified options.
//
// To apply RunModel on all the test files in a directory,
// use datadriven.Walk.
func RunModel(t *testing.T, path string, m tea.Model, opts ...Option) {
t.Helper()
d := NewDriver(m, opts...)
defer d.Close(t)
datadriven.RunTest(t, path, func(t *testing.T, td *datadriven.TestData) string {
t.Helper()
return d.RunOneTest(t, td)
})
}
// RunModelFromString is a version of RunModel which takes the input
// test directives from a string directly.
func RunModelFromString(t *testing.T, input string, m tea.Model, opts ...Option) {
t.Helper()
d := NewDriver(m, opts...)
defer d.Close(t)
datadriven.RunTestFromString(t, input, func(t *testing.T, td *datadriven.TestData) string {
t.Helper()
return d.RunOneTest(t, td)
})
}