Skip to content

Commit 5b8c4f2

Browse files
committed
grpc: test: go doesn't like it when we create new listeners in different tests, so make all the server tests under a single TestServer func and everything else a subtest
1 parent 1d8a205 commit 5b8c4f2

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

grpc/server/server_test.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,9 @@ func TestServer(t *testing.T) {
140140
app.Config.UsernameIsEmail = true
141141

142142
// run against a real database if the test isn't run with -test.short flag
143-
// if !testing.Short() {
144-
// app = setup(t, logger)
145-
// }
143+
if !testing.Short() {
144+
app = setup(t, logger)
145+
}
146146

147147
// start a fake oauth provider
148148
providerServer := httptest.NewServer(test.ProviderApp())
@@ -611,7 +611,8 @@ func TestServer(t *testing.T) {
611611
assert.NotEmpty(t, res)
612612
})
613613
})
614-
t.Run("testRESTInterface", testRESTInterface)
614+
t.Run("Test REST Interface", testRESTInterface)
615+
t.Run("Test gRPC Interface", testGRPCInterface)
615616
}
616617

617618
func testRESTInterface(t *testing.T) {
@@ -637,9 +638,9 @@ func testRESTInterface(t *testing.T) {
637638
testApp.Config.ServerPort = 9191
638639

639640
// run against a real database if the test isn't run with -test.short flag
640-
// if !testing.Short() {
641-
// testApp = setup(t, logger)
642-
// }
641+
if !testing.Short() {
642+
testApp = setup(t, logger)
643+
}
643644

644645
// parent context for servers
645646
ctx := context.Background()
@@ -1482,7 +1483,7 @@ func testPublicRESTInterface(testApp *app.App, client *route.Client) func(*testi
14821483
}
14831484
}
14841485

1485-
func TestGRPCInterface(t *testing.T) {
1486+
func testGRPCInterface(t *testing.T) {
14861487
// Default logger
14871488
logger := logrus.New()
14881489
logger.Formatter = &logrus.JSONFormatter{}
@@ -1505,9 +1506,9 @@ func TestGRPCInterface(t *testing.T) {
15051506
testApp.Config.ServerPort = 9292
15061507

15071508
// run against a real database if the test isn't run with -test.short flag
1508-
// if !testing.Short() {
1509-
// testApp = setup(t, logger)
1510-
// }
1509+
if !testing.Short() {
1510+
testApp = setup(t, logger)
1511+
}
15111512

15121513
// We still want the username to be an email for testing purposes
15131514
testApp.Config.UsernameIsEmail = true

0 commit comments

Comments
 (0)