Skip to content

Commit

Permalink
grpc: test: go doesn't like it when we create new listeners in differ…
Browse files Browse the repository at this point in the history
…ent tests, so make all the server tests under a single TestServer func and everything else a subtest
  • Loading branch information
mohammed90 committed Aug 21, 2019
1 parent 1d8a205 commit 5b8c4f2
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions grpc/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ func TestServer(t *testing.T) {
app.Config.UsernameIsEmail = true

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

// start a fake oauth provider
providerServer := httptest.NewServer(test.ProviderApp())
Expand Down Expand Up @@ -611,7 +611,8 @@ func TestServer(t *testing.T) {
assert.NotEmpty(t, res)
})
})
t.Run("testRESTInterface", testRESTInterface)
t.Run("Test REST Interface", testRESTInterface)
t.Run("Test gRPC Interface", testGRPCInterface)
}

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

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

// parent context for servers
ctx := context.Background()
Expand Down Expand Up @@ -1482,7 +1483,7 @@ func testPublicRESTInterface(testApp *app.App, client *route.Client) func(*testi
}
}

func TestGRPCInterface(t *testing.T) {
func testGRPCInterface(t *testing.T) {
// Default logger
logger := logrus.New()
logger.Formatter = &logrus.JSONFormatter{}
Expand All @@ -1505,9 +1506,9 @@ func TestGRPCInterface(t *testing.T) {
testApp.Config.ServerPort = 9292

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

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

0 comments on commit 5b8c4f2

Please sign in to comment.