-
Notifications
You must be signed in to change notification settings - Fork 1
/
method_test.go
59 lines (52 loc) · 1.32 KB
/
method_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
55
56
57
58
59
package kivikmock
import (
"testing"
"gitlab.com/flimzy/testy"
)
type methodTest struct {
input expectation
standard string
verbose string
}
func testMethod(t *testing.T, test methodTest) {
result := test.input.method(false)
if result != test.standard {
t.Errorf("Unexpected method(false) output.\nWant: %s\n Got: %s\n", test.standard, result)
}
result = test.input.method(true)
if result != test.verbose {
t.Errorf("Unexpected method(true) output.\nWant: %s\n Got: %s\n", test.verbose, result)
}
}
func TestCloseMethod(t *testing.T) {
tests := testy.NewTable()
tests.Add("empty", methodTest{
input: &ExpectedClose{},
standard: "Close()",
verbose: "Close()",
})
tests.Run(t, testMethod)
}
func TestAuthenticateMethod(t *testing.T) {
tests := testy.NewTable()
tests.Add("empty", methodTest{
input: &ExpectedAuthenticate{},
standard: "Authenticate()",
verbose: "Authenticate(ctx, ?)",
})
tests.Add("authenticator", methodTest{
input: &ExpectedAuthenticate{authType: "foo"},
standard: "Authenticate()",
verbose: "Authenticate(ctx, <foo>)",
})
tests.Run(t, testMethod)
}
func TestDBCloseMethod(t *testing.T) {
tests := testy.NewTable()
tests.Add("empty", methodTest{
input: &ExpectedDBClose{},
standard: "DB.Close()",
verbose: "DB.Close(ctx)",
})
tests.Run(t, testMethod)
}