File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed
Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change 55 "net/http"
66 "net/http/httptest"
77 "testing"
8+ "time"
89
910 "github.com/stretchr/testify/assert"
1011)
@@ -61,3 +62,41 @@ func TestGetStats(t *testing.T) {
6162
6263 assert .Equal (t , data ["total_count" ].(float64 ), float64 (1 ))
6364}
65+
66+ func TestRace (t * testing.T ) {
67+ s := New ()
68+
69+ ch1 := make (chan bool )
70+ ch2 := make (chan bool )
71+
72+ go func () {
73+ now := time .Now ()
74+ for true {
75+ select {
76+ case _ = <- ch1 :
77+ return
78+ default :
79+ s .EndWithStatus (now , 200 )
80+
81+ }
82+ }
83+
84+ }()
85+
86+ go func () {
87+ dt := s .Data ()
88+ for true {
89+ select {
90+ case _ = <- ch2 :
91+ return
92+ default :
93+ _ = dt .TotalStatusCodeCount ["200" ]
94+ }
95+ }
96+ }()
97+
98+ time .Sleep (time .Second )
99+
100+ ch1 <- true
101+ ch2 <- true
102+ }
You can’t perform that action at this time.
0 commit comments