github.com/go-kivik/kivik/v4@v4.3.2/mockdb/gen/main_test.go (about) 1 // Licensed under the Apache License, Version 2.0 (the "License"); you may not 2 // use this file except in compliance with the License. You may obtain a copy of 3 // the License at 4 // 5 // http://www.apache.org/licenses/LICENSE-2.0 6 // 7 // Unless required by applicable law or agreed to in writing, software 8 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 9 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 10 // License for the specific language governing permissions and limitations under 11 // the License. 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 }