make testclient threadsafe by guarding internal state with accessors

This commit is contained in:
Mike Danese
2015-07-06 14:37:46 -07:00
parent 59611d7160
commit 1b84fb7d74
28 changed files with 151 additions and 99 deletions

View File

@@ -462,9 +462,10 @@ func TestTokenCreation(t *testing.T) {
controller.secretDeleted(tc.DeletedSecret)
}
for i, action := range client.Actions {
actions := client.Actions()
for i, action := range actions {
if len(tc.ExpectedActions) < i+1 {
t.Errorf("%s: %d unexpected actions: %+v", k, len(client.Actions)-len(tc.ExpectedActions), client.Actions[i:])
t.Errorf("%s: %d unexpected actions: %+v", k, len(actions)-len(tc.ExpectedActions), actions[i:])
break
}
@@ -479,8 +480,8 @@ func TestTokenCreation(t *testing.T) {
}
}
if len(tc.ExpectedActions) > len(client.Actions) {
t.Errorf("%s: %d additional expected actions:%+v", k, len(tc.ExpectedActions)-len(client.Actions), tc.ExpectedActions[len(client.Actions):])
if len(tc.ExpectedActions) > len(actions) {
t.Errorf("%s: %d additional expected actions:%+v", k, len(tc.ExpectedActions)-len(actions), tc.ExpectedActions[len(actions):])
}
}
}