...
1
2
3
4
5
6
7
8
9
10
11
12
13 package mockdb
14
15 import (
16 "testing"
17
18 "gitlab.com/flimzy/testy"
19 )
20
21 type methodTest struct {
22 input expectation
23 standard string
24 verbose string
25 }
26
27 func testMethod(t *testing.T, test methodTest) {
28 t.Helper()
29 result := test.input.method(false)
30 if result != test.standard {
31 t.Errorf("Unexpected method(false) output.\nWant: %s\n Got: %s\n", test.standard, result)
32 }
33 result = test.input.method(true)
34 if result != test.verbose {
35 t.Errorf("Unexpected method(true) output.\nWant: %s\n Got: %s\n", test.verbose, result)
36 }
37 }
38
39 func TestCloseMethod(t *testing.T) {
40 tests := testy.NewTable()
41 tests.Add("empty", methodTest{
42 input: &ExpectedClose{},
43 standard: "Close()",
44 verbose: "Close()",
45 })
46 tests.Run(t, testMethod)
47 }
48
49 func TestDBCloseMethod(t *testing.T) {
50 tests := testy.NewTable()
51 tests.Add("empty", methodTest{
52 input: &ExpectedDBClose{},
53 standard: "DB.Close()",
54 verbose: "DB.Close(ctx)",
55 })
56 tests.Run(t, testMethod)
57 }
58
View as plain text