mirror of
https://github.com/opentffoundation/opentf.git
synced 2025-12-25 01:00:16 -05:00
refactor: add err checks (#2896)
Signed-off-by: Larry Bordowitz <laurence.bordowitz@gmail.com>
This commit is contained in:
@@ -66,14 +66,20 @@ func TestStateHookStopping(t *testing.T) {
|
||||
// We'll now force lastPersist to be long enough ago that persisting
|
||||
// should be due on the next call.
|
||||
hook.intermediatePersist.LastPersist = time.Now().Add(-5 * time.Hour)
|
||||
hook.PostStateUpdate(s)
|
||||
_, err = hook.PostStateUpdate(s)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error from PostStateUpdate: %s", err)
|
||||
}
|
||||
if is.Written == nil || !is.Written.Equal(s) {
|
||||
t.Fatalf("mismatching state written")
|
||||
}
|
||||
if is.Persisted == nil || !is.Persisted.Equal(s) {
|
||||
t.Fatalf("mismatching state persisted")
|
||||
}
|
||||
hook.PostStateUpdate(s)
|
||||
_, err = hook.PostStateUpdate(s)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error from PostStateUpdate: %s", err)
|
||||
}
|
||||
if is.Written == nil || !is.Written.Equal(s) {
|
||||
t.Fatalf("mismatching state written")
|
||||
}
|
||||
@@ -108,12 +114,18 @@ func TestStateHookStopping(t *testing.T) {
|
||||
}
|
||||
|
||||
is.Persisted = nil
|
||||
hook.PostStateUpdate(s)
|
||||
_, err = hook.PostStateUpdate(s)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error from PostStateUpdate: %s", err)
|
||||
}
|
||||
if is.Persisted == nil || !is.Persisted.Equal(s) {
|
||||
t.Fatalf("mismatching state persisted")
|
||||
}
|
||||
is.Persisted = nil
|
||||
hook.PostStateUpdate(s)
|
||||
_, err = hook.PostStateUpdate(s)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error from PostStateUpdate: %s", err)
|
||||
}
|
||||
if is.Persisted == nil || !is.Persisted.Equal(s) {
|
||||
t.Fatalf("mismatching state persisted")
|
||||
}
|
||||
@@ -165,14 +177,20 @@ func TestStateHookCustomPersistRule(t *testing.T) {
|
||||
// We'll now force lastPersist to be long enough ago that persisting
|
||||
// should be due on the next call.
|
||||
hook.intermediatePersist.LastPersist = time.Now().Add(-5 * time.Hour)
|
||||
hook.PostStateUpdate(s)
|
||||
_, err = hook.PostStateUpdate(s)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error from PostStateUpdate: %s", err)
|
||||
}
|
||||
if is.Written == nil || !is.Written.Equal(s) {
|
||||
t.Fatalf("mismatching state written")
|
||||
}
|
||||
if is.Persisted != nil {
|
||||
t.Fatalf("has a persisted state, but shouldn't")
|
||||
}
|
||||
hook.PostStateUpdate(s)
|
||||
_, err = hook.PostStateUpdate(s)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error from PostStateUpdate: %s", err)
|
||||
}
|
||||
if is.Written == nil || !is.Written.Equal(s) {
|
||||
t.Fatalf("mismatching state written")
|
||||
}
|
||||
@@ -212,12 +230,18 @@ func TestStateHookCustomPersistRule(t *testing.T) {
|
||||
}
|
||||
|
||||
is.Persisted = nil
|
||||
hook.PostStateUpdate(s)
|
||||
_, err = hook.PostStateUpdate(s)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error from PostStateUpdate: %s", err)
|
||||
}
|
||||
if is.Persisted == nil || !is.Persisted.Equal(s) {
|
||||
t.Fatalf("mismatching state persisted")
|
||||
}
|
||||
is.Persisted = nil
|
||||
hook.PostStateUpdate(s)
|
||||
_, err = hook.PostStateUpdate(s)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error from PostStateUpdate: %s", err)
|
||||
}
|
||||
if is.Persisted == nil || !is.Persisted.Equal(s) {
|
||||
t.Fatalf("mismatching state persisted")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user