helper/resource: Fix WaitForState tests

This commit is contained in:
Radek Simko 2016-08-27 15:11:09 +01:00
parent 37be25b312
commit aef2513b44
No known key found for this signature in database
GPG Key ID: 6823F3DCCE01BB19
1 changed files with 23 additions and 8 deletions

View File

@ -75,7 +75,8 @@ func TestWaitForState_inconsistent_positive(t *testing.T) {
Pending: []string{"replicating"}, Pending: []string{"replicating"},
Target: []string{"done"}, Target: []string{"done"},
Refresh: InconsistentStateRefreshFunc(), Refresh: InconsistentStateRefreshFunc(),
Timeout: 10 * time.Second, Timeout: 90 * time.Millisecond,
PollInterval: 10 * time.Millisecond,
ContinuousTargetOccurence: 3, ContinuousTargetOccurence: 3,
} }
@ -95,14 +96,19 @@ func TestWaitForState_inconsistent_negative(t *testing.T) {
Pending: []string{"replicating"}, Pending: []string{"replicating"},
Target: []string{"done"}, Target: []string{"done"},
Refresh: InconsistentStateRefreshFunc(), Refresh: InconsistentStateRefreshFunc(),
Timeout: 10 * time.Second, Timeout: 90 * time.Millisecond,
PollInterval: 10 * time.Millisecond,
ContinuousTargetOccurence: 4, ContinuousTargetOccurence: 4,
} }
_, err := conf.WaitForState() _, err := conf.WaitForState()
if err == nil && err.Error() != "timeout while waiting for state to become 'done'" { if err == nil {
t.Fatalf("err: %s", err) t.Fatal("Expected timeout error. No error returned.")
}
expectedErr := "timeout while waiting for state to become 'done'"
if err.Error() != expectedErr {
t.Fatalf("Errors don't match.\nExpected: %q\nGiven: %q\n", expectedErr, err.Error())
} }
} }
@ -116,8 +122,13 @@ func TestWaitForState_timeout(t *testing.T) {
obj, err := conf.WaitForState() obj, err := conf.WaitForState()
if err == nil && err.Error() != "timeout while waiting for state to become 'running'" { if err == nil {
t.Fatalf("err: %s", err) t.Fatal("Expected timeout error. No error returned.")
}
expectedErr := "timeout while waiting for state to become 'running'"
if err.Error() != expectedErr {
t.Fatalf("Errors don't match.\nExpected: %q\nGiven: %q\n", expectedErr, err.Error())
} }
if obj != nil { if obj != nil {
@ -171,8 +182,12 @@ func TestWaitForState_failure(t *testing.T) {
} }
obj, err := conf.WaitForState() obj, err := conf.WaitForState()
if err == nil && err.Error() != "failed" { if err == nil {
t.Fatalf("err: %s", err) t.Fatal("Expected error. No error returned.")
}
expectedErr := "failed"
if err.Error() != expectedErr {
t.Fatalf("Errors don't match.\nExpected: %q\nGiven: %q\n", expectedErr, err.Error())
} }
if obj != nil { if obj != nil {
t.Fatalf("should not return obj") t.Fatalf("should not return obj")