Skip to content

Commit 7141fa6

Browse files
committed
Remove unused method
1 parent 346c097 commit 7141fa6

File tree

2 files changed

+0
-52
lines changed

2 files changed

+0
-52
lines changed

coderd/database/dbfake/dbfake.go

-8
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,6 @@ import (
2727

2828
var validProxyByHostnameRegex = regexp.MustCompile(`^[a-zA-Z0-9._-]+$`)
2929

30-
// FakeDatabase is helpful for knowing if the underlying db is an in memory fake
31-
// database. This is only in the databasefake package, so will only be used
32-
// by unit tests.
33-
type FakeDatabase interface {
34-
IsFakeDB()
35-
}
36-
3730
var errDuplicateKey = &pq.Error{
3831
Code: "23505",
3932
Message: "duplicate key value violates unique constraint",
@@ -218,7 +211,6 @@ func validateDatabaseType(args interface{}) error {
218211
return nil
219212
}
220213

221-
func (fakeQuerier) IsFakeDB() {}
222214
func (*fakeQuerier) Ping(_ context.Context) (time.Duration, error) {
223215
return 0, nil
224216
}

coderd/database/dbfake/dbfake_test.go

-44
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package dbfake_test
33
import (
44
"context"
55
"database/sql"
6-
"fmt"
76
"reflect"
87
"sort"
98
"testing"
@@ -64,49 +63,6 @@ func TestInTx(t *testing.T) {
6463
}
6564
}
6665

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-
11066
// TestUserOrder ensures that the fake database returns users sorted by username.
11167
func TestUserOrder(t *testing.T) {
11268
t.Parallel()

0 commit comments

Comments
 (0)