File tree 7 files changed +48
-38
lines changed
7 files changed +48
-38
lines changed Original file line number Diff line number Diff line change @@ -41,11 +41,11 @@ go_test(
41
41
# by default gazelle tries to add all the test files to the first
42
42
# go_test; we need to exclude the tests that we want to configure
43
43
# in a particular way
44
- # gazelle:exclude racy_test .go
44
+ # gazelle:exclude service_norace_test .go
45
45
46
46
go_test (
47
- name = "go_racy_test " ,
48
- srcs = ["racy_test .go" ],
47
+ name = "go_norace_test " ,
48
+ srcs = ["service_norace_test .go" ],
49
49
embed = [":go_default_library" ],
50
50
race = "off" , # TODO(#377): fix issues with race detection testing.
51
51
deps = [
File renamed without changes.
Original file line number Diff line number Diff line change @@ -52,11 +52,11 @@ go_test(
52
52
# by default gazelle tries to add all the test files to the first
53
53
# go_test; we need to exclude the tests that we want to configure
54
54
# in a particular way
55
- # gazelle:exclude racy_test .go
55
+ # gazelle:exclude service_norace_test .go
56
56
57
57
go_test (
58
- name = "go_racy_test " ,
59
- srcs = ["racy_test .go" ],
58
+ name = "go_norace_test " ,
59
+ srcs = ["service_norace_test .go" ],
60
60
embed = [":go_default_library" ],
61
61
race = "off" , # TODO(#377): fix issues with race detection testing.
62
62
deps = [
File renamed without changes.
Original file line number Diff line number Diff line change @@ -55,11 +55,15 @@ go_test(
55
55
# by default gazelle tries to add all the test files to the first
56
56
# go_test; we need to exclude the tests that we want to configure
57
57
# in a particular way
58
- # gazelle:exclude racy_test.go
58
+ # gazelle:exclude discovery_norace_test.go
59
+ # gazelle:exclude service_norace_test.go
59
60
60
61
go_test (
61
- name = "go_racy_test" ,
62
- srcs = ["racy_test.go" ],
62
+ name = "go_norace_test" ,
63
+ srcs = [
64
+ "discovery_norace_test.go" ,
65
+ "service_norace_test.go" ,
66
+ ],
63
67
embed = [":go_default_library" ],
64
68
race = "off" , # TODO(#377): fix issues with race detection testing.
65
69
deps = [
Original file line number Diff line number Diff line change @@ -10,7 +10,6 @@ import (
10
10
swarmt "github.com/libp2p/go-libp2p-swarm/testing"
11
11
mdns "github.com/libp2p/go-libp2p/p2p/discovery"
12
12
bhost "github.com/libp2p/go-libp2p/p2p/host/basic"
13
- logTest "github.com/sirupsen/logrus/hooks/test"
14
13
)
15
14
16
15
var _ = mdns .Notifee (& discovery {})
@@ -63,31 +62,3 @@ func TestStartDiscovery_HandlePeerFound(t *testing.T) {
63
62
expectPeers (t , a , 2 )
64
63
expectPeers (t , b , 2 )
65
64
}
66
-
67
- func TestLifecycle (t * testing.T ) {
68
- hook := logTest .NewGlobal ()
69
-
70
- s , err := NewServer ()
71
- if err != nil {
72
- t .Fatalf ("Could not start a new server: %v" , err )
73
- }
74
-
75
- s .Start ()
76
- msg := hook .Entries [0 ].Message
77
- want := "Starting service"
78
- if msg != want {
79
- t .Errorf ("incorrect log. wanted: %s. got: %v" , want , msg )
80
- }
81
-
82
- s .Stop ()
83
- msg = hook .LastEntry ().Message
84
- want = "Stopping service"
85
- if msg != want {
86
- t .Errorf ("incorrect log. wanted: %s. got: %v" , want , msg )
87
- }
88
-
89
- // The context should have been cancelled.
90
- if s .ctx .Err () == nil {
91
- t .Error ("Context was not cancelled" )
92
- }
93
- }
Original file line number Diff line number Diff line change
1
+ package p2p
2
+
3
+ import (
4
+ "testing"
5
+
6
+ logTest "github.com/sirupsen/logrus/hooks/test"
7
+ )
8
+
9
+ func TestLifecycle (t * testing.T ) {
10
+ hook := logTest .NewGlobal ()
11
+
12
+ s , err := NewServer ()
13
+ if err != nil {
14
+ t .Fatalf ("Could not start a new server: %v" , err )
15
+ }
16
+
17
+ s .Start ()
18
+ msg := hook .Entries [0 ].Message
19
+ want := "Starting service"
20
+ if msg != want {
21
+ t .Errorf ("incorrect log. wanted: %s. got: %v" , want , msg )
22
+ }
23
+
24
+ s .Stop ()
25
+ msg = hook .LastEntry ().Message
26
+ want = "Stopping service"
27
+ if msg != want {
28
+ t .Errorf ("incorrect log. wanted: %s. got: %v" , want , msg )
29
+ }
30
+
31
+ // The context should have been cancelled.
32
+ if s .ctx .Err () == nil {
33
+ t .Error ("Context was not cancelled" )
34
+ }
35
+ }
You can’t perform that action at this time.
0 commit comments