Skip to content

Commit

Permalink
sriov: added unit test for PullOperatorConfig func (openshift-kni#319)
Browse files Browse the repository at this point in the history
Co-authored-by: nkononov <[email protected]>
  • Loading branch information
kononovn and nkononov authored Apr 4, 2024
1 parent 59978c1 commit c548f69
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/sriov/operatorconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ func (builder *OperatorConfigBuilder) Create() (*OperatorConfigBuilder, error) {
func PullOperatorConfig(apiClient *clients.Settings, nsname string) (*OperatorConfigBuilder, error) {
glog.V(100).Infof("Pulling existing default SriovOperatorConfig: %s", sriovOperatorConfigName)

if apiClient == nil {
glog.V(100).Infof("The apiClient is empty")

return nil, fmt.Errorf("SriovOperatorConfig 'apiClient' cannot be empty")
}

builder := OperatorConfigBuilder{
apiClient: apiClient.ClientSrIov,
Definition: &srIovV1.SriovOperatorConfig{
Expand Down
7 changes: 7 additions & 0 deletions pkg/sriov/operatorconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ func TestPullOperatorConfig(t *testing.T) {
addToRuntimeObjects: true,
client: true,
},
{
operatorConfigNamespace: "test-namespace",
expectedError: true,
expectedErrorText: "SriovOperatorConfig 'apiClient' cannot be empty",
addToRuntimeObjects: true,
client: false,
},
{
operatorConfigNamespace: "test-namespace",
expectedError: true,
Expand Down

0 comments on commit c548f69

Please sign in to comment.