Skip to content

Commit

Permalink
pkg/operator: add test for inClusterBringUp staying on error
Browse files Browse the repository at this point in the history
Signed-off-by: Antonio Murdaca <runcom@linux.com>
  • Loading branch information
runcom committed Feb 17, 2019
1 parent e1c97fd commit 2a582a9
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions pkg/operator/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -576,3 +576,29 @@ func TestOperatorSyncStatus(t *testing.T) {
}
}
}

func TestInClusterBringUpStayOnErr(t *testing.T) {
optr := &Operator{}
optr.vStore = newVersionStore()
optr.vStore.Set("operator", "test-version")
optr.mcpLister = &mockMCPLister{}
co := &configv1.ClusterOperator{}
optr.configClient = &mockClusterOperatorsClient{co: co}
optr.inClusterBringup = true

fn1 := func(config renderConfig) error {
return errors.New("mocked fn1")
}
err := optr.syncAll(renderConfig{}, []syncFunc{{name: "mock1", fn: fn1}})
assert.NotNil(t, err, "expected syncAll to fail")

assert.True(t, optr.inClusterBringup)

fn1 = func(config renderConfig) error {
return nil
}
err = optr.syncAll(renderConfig{}, []syncFunc{{name: "mock1", fn: fn1}})
assert.Nil(t, err, "expected syncAll to pass")

assert.False(t, optr.inClusterBringup)
}

0 comments on commit 2a582a9

Please sign in to comment.