...
1
2
3
4
5
6
7
8
9
10
11
12
13 package main
14
15 import (
16 "testing"
17
18 "gitlab.com/flimzy/testy"
19 )
20
21 func TestCompareMethods(t *testing.T) {
22 type tst struct {
23 client []*method
24 driver []*method
25 expSame []*method
26 expClient []*method
27 expDriver []*method
28 }
29 tests := testy.NewTable()
30 tests.Add("one identical", tst{
31 client: []*method{
32 {Name: "Foo"},
33 },
34 driver: []*method{
35 {Name: "Foo"},
36 },
37 expSame: []*method{
38 {Name: "Foo"},
39 },
40 expClient: []*method{},
41 expDriver: []*method{},
42 })
43 tests.Add("same name", tst{
44 client: []*method{
45 {Name: "Foo", ReturnsError: true},
46 },
47 driver: []*method{
48 {Name: "Foo"},
49 },
50 expSame: []*method{},
51 expClient: []*method{
52 {Name: "Foo", ReturnsError: true},
53 },
54 expDriver: []*method{
55 {Name: "Foo"},
56 },
57 })
58
59 tests.Run(t, func(t *testing.T, test tst) {
60 same, client, driver := compareMethods(test.client, test.driver)
61 if d := testy.DiffInterface(test.expSame, same); d != nil {
62 t.Errorf("Same:\n%s\n", d)
63 }
64 if d := testy.DiffInterface(test.expClient, client); d != nil {
65 t.Errorf("Same:\n%s\n", d)
66 }
67 if d := testy.DiffInterface(test.expDriver, driver); d != nil {
68 t.Errorf("Same:\n%s\n", d)
69 }
70 })
71 }
72
View as plain text