From 24ac26b3c1500026d7912ac160b27eb8464dc345 Mon Sep 17 00:00:00 2001 From: Wojciech Bederski Date: Fri, 11 Sep 2015 17:52:57 +0200 Subject: [PATCH] failing test showing that nested Pause()/Resume() release too early see: #1173 / https://github.com/hashicorp/consul/issues/1173 --- command/agent/local_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/command/agent/local_test.go b/command/agent/local_test.go index 997860279..bc525d278 100644 --- a/command/agent/local_test.go +++ b/command/agent/local_test.go @@ -664,6 +664,29 @@ func TestAgent_checkTokens(t *testing.T) { } } +func TestAgent_nestedPauseResume(t *testing.T) { + l := new(localState) + if l.isPaused() != false { + t.Fatal("localState should be unPaused after init") + } + l.Pause() + if l.isPaused() != true { + t.Fatal("localState should be Paused after first call to Pause()") + } + l.Pause() + if l.isPaused() != true { + t.Fatal("localState should STILL be Paused after second call to Pause()") + } + l.Resume() + if l.isPaused() != true { + t.Fatal("localState should STILL be Paused after FIRST call to Resume()") + } + l.Resume() + if l.isPaused() != false { + t.Fatal("localState should NOT be Paused after SECOND call to Resume()") + } +} + var testRegisterRules = ` service "api" { policy = "write"