Skip to content

Commit

Permalink
oversight: add mutex to the read site of expectedOrder
Browse files Browse the repository at this point in the history
  • Loading branch information
ucirello committed Nov 23, 2021
1 parent 4042134 commit 7950d93
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -957,6 +957,8 @@ func TestTree_shutdownOrder(t *testing.T) {
<-treeStarted
tree.GracefulShutdown(context.Background())
wg.Wait()
mu.Lock()
defer mu.Unlock()
expectedOrder := []string{"child-3", "child-2", "child-1", "child-0"}
if !reflect.DeepEqual(expectedOrder, gotOrder) {
t.Error("unexpected shutdown order:", gotOrder)
Expand Down Expand Up @@ -1012,6 +1014,8 @@ func TestTree_shutdownOrder(t *testing.T) {
tree.GracefulShutdown(shutdownCtx)
wg.Wait()
expectedOrder := []string{"child-3"}
mu.Lock()
defer mu.Unlock()
if !reflect.DeepEqual(expectedOrder, gotOrder) {
t.Error("unexpected shutdown order:", gotOrder)
}
Expand Down

0 comments on commit 7950d93

Please sign in to comment.