@@ -3,7 +3,6 @@ package dbfake_test
3
3
import (
4
4
"context"
5
5
"database/sql"
6
- "fmt"
7
6
"reflect"
8
7
"sort"
9
8
"testing"
@@ -64,49 +63,6 @@ func TestInTx(t *testing.T) {
64
63
}
65
64
}
66
65
67
- // TestExactMethods will ensure the fake database does not hold onto excessive
68
- // functions. The fake database is a manual implementation, so it is possible
69
- // we forget to delete functions that we remove. This unit test just ensures
70
- // we remove the extra methods.
71
- func TestExactMethods (t * testing.T ) {
72
- t .Parallel ()
73
-
74
- // extraFakeMethods contains the extra allowed methods that are not a part
75
- // of the database.Store interface.
76
- extraFakeMethods := map [string ]string {
77
- // Example
78
- // "SortFakeLists": "Helper function used",
79
- "IsFakeDB" : "Helper function used for unit testing" ,
80
- }
81
-
82
- fake := reflect .TypeOf (dbfake .New ())
83
- fakeMethods := methods (fake )
84
-
85
- store := reflect .TypeOf ((* database .Store )(nil )).Elem ()
86
- storeMethods := methods (store )
87
-
88
- // Store should be a subset
89
- for k := range storeMethods {
90
- _ , ok := fakeMethods [k ]
91
- if ! ok {
92
- panic (fmt .Sprintf ("This should never happen. FakeDB missing method %s, so doesn't fit the interface" , k ))
93
- }
94
- delete (storeMethods , k )
95
- delete (fakeMethods , k )
96
- }
97
-
98
- for k := range fakeMethods {
99
- _ , ok := extraFakeMethods [k ]
100
- if ok {
101
- continue
102
- }
103
- // If you are seeing this error, you have an extra function not required
104
- // for the database.Store. If you still want to keep it, add it to
105
- // 'extraFakeMethods' to allow it.
106
- t .Errorf ("Fake method '%s()' is excessive and not needed to fit interface, delete it" , k )
107
- }
108
- }
109
-
110
66
// TestUserOrder ensures that the fake database returns users sorted by username.
111
67
func TestUserOrder (t * testing.T ) {
112
68
t .Parallel ()
0 commit comments