-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tests): improved tests coverage unit/integration (#177)
* feat(tests): improved tests coverage unit/integration Signed-off-by: Alessio Pragliola <seth.pro@gmail.com> * fix(ci): missing folder in Dockerfile Signed-off-by: Alessio Pragliola <seth.pro@gmail.com> --------- Signed-off-by: Alessio Pragliola <seth.pro@gmail.com>
- Loading branch information
1 parent
ff22865
commit 21c0883
Showing
19 changed files
with
1,444 additions
and
367 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package v1alpha1_test | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
|
||
"github.com/opendatahub-io/model-registry-operator/api/v1alpha1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
func TestHandleAnnotations(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
annotations map[string]string | ||
wantAnnotations map[string]string | ||
mrRestImage string | ||
wantMrRestImage string | ||
}{ | ||
{ | ||
name: "no handler annotations", | ||
annotations: map[string]string{ | ||
"modelregistry.opendatahub.io/other-annotation": "true", | ||
}, | ||
wantAnnotations: map[string]string{ | ||
"modelregistry.opendatahub.io/other-annotation": "true", | ||
}, | ||
mrRestImage: "test", | ||
wantMrRestImage: "test", | ||
}, | ||
{ | ||
name: "reset defaults", | ||
annotations: map[string]string{ | ||
"modelregistry.opendatahub.io/reset-spec-defaults": "", | ||
}, | ||
wantAnnotations: map[string]string{}, | ||
mrRestImage: "test", | ||
wantMrRestImage: "", | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
mr := &v1alpha1.ModelRegistry{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Annotations: tt.annotations, | ||
}, | ||
Spec: v1alpha1.ModelRegistrySpec{ | ||
Rest: v1alpha1.RestSpec{ | ||
Image: tt.mrRestImage, | ||
}, | ||
}, | ||
} | ||
mr.HandleAnnotations() | ||
|
||
if !reflect.DeepEqual(mr.GetAnnotations(), tt.wantAnnotations) { | ||
t.Errorf("HandleAnnotations() = %v, want %v", mr.GetAnnotations(), tt.wantAnnotations) | ||
} | ||
|
||
if mr.Spec.Rest.Image != tt.wantMrRestImage { | ||
t.Errorf("HandleAnnotations() = %v, want %v", mr.Name, tt.wantMrRestImage) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.