Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
fgimenez committed Aug 10, 2018
1 parent 69b7fed commit cc5559d
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 38 deletions.
6 changes: 3 additions & 3 deletions client/proposer/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ go_test(
# by default gazelle tries to add all the test files to the first
# go_test; we need to exclude the tests that we want to configure
# in a particular way
# gazelle:exclude racy_test.go
# gazelle:exclude service_norace_test.go

go_test(
name = "go_racy_test",
srcs = ["racy_test.go"],
name = "go_norace_test",
srcs = ["service_norace_test.go"],
embed = [":go_default_library"],
race = "off", # TODO(#377): fix issues with race detection testing.
deps = [
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions client/syncer/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ go_test(
# by default gazelle tries to add all the test files to the first
# go_test; we need to exclude the tests that we want to configure
# in a particular way
# gazelle:exclude racy_test.go
# gazelle:exclude service_norace_test.go

go_test(
name = "go_racy_test",
srcs = ["racy_test.go"],
name = "go_norace_test",
srcs = ["service_norace_test.go"],
embed = [":go_default_library"],
race = "off", # TODO(#377): fix issues with race detection testing.
deps = [
Expand Down
File renamed without changes.
10 changes: 7 additions & 3 deletions shared/p2p/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,15 @@ go_test(
# by default gazelle tries to add all the test files to the first
# go_test; we need to exclude the tests that we want to configure
# in a particular way
# gazelle:exclude racy_test.go
# gazelle:exclude discovery_norace_test.go
# gazelle:exclude service_norace_test.go

go_test(
name = "go_racy_test",
srcs = ["racy_test.go"],
name = "go_norace_test",
srcs = [
"discovery_norace_test.go",
"service_norace_test.go",
],
embed = [":go_default_library"],
race = "off", # TODO(#377): fix issues with race detection testing.
deps = [
Expand Down
29 changes: 0 additions & 29 deletions shared/p2p/racy_test.go → shared/p2p/discovery_norace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
swarmt "github.com/libp2p/go-libp2p-swarm/testing"
mdns "github.com/libp2p/go-libp2p/p2p/discovery"
bhost "github.com/libp2p/go-libp2p/p2p/host/basic"
logTest "github.com/sirupsen/logrus/hooks/test"
)

var _ = mdns.Notifee(&discovery{})
Expand Down Expand Up @@ -63,31 +62,3 @@ func TestStartDiscovery_HandlePeerFound(t *testing.T) {
expectPeers(t, a, 2)
expectPeers(t, b, 2)
}

func TestLifecycle(t *testing.T) {
hook := logTest.NewGlobal()

s, err := NewServer()
if err != nil {
t.Fatalf("Could not start a new server: %v", err)
}

s.Start()
msg := hook.Entries[0].Message
want := "Starting service"
if msg != want {
t.Errorf("incorrect log. wanted: %s. got: %v", want, msg)
}

s.Stop()
msg = hook.LastEntry().Message
want = "Stopping service"
if msg != want {
t.Errorf("incorrect log. wanted: %s. got: %v", want, msg)
}

// The context should have been cancelled.
if s.ctx.Err() == nil {
t.Error("Context was not cancelled")
}
}
35 changes: 35 additions & 0 deletions shared/p2p/service_norace_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package p2p

import (
"testing"

logTest "github.com/sirupsen/logrus/hooks/test"
)

func TestLifecycle(t *testing.T) {
hook := logTest.NewGlobal()

s, err := NewServer()
if err != nil {
t.Fatalf("Could not start a new server: %v", err)
}

s.Start()
msg := hook.Entries[0].Message
want := "Starting service"
if msg != want {
t.Errorf("incorrect log. wanted: %s. got: %v", want, msg)
}

s.Stop()
msg = hook.LastEntry().Message
want = "Stopping service"
if msg != want {
t.Errorf("incorrect log. wanted: %s. got: %v", want, msg)
}

// The context should have been cancelled.
if s.ctx.Err() == nil {
t.Error("Context was not cancelled")
}
}

0 comments on commit cc5559d

Please sign in to comment.