Skip to content

Commit

Permalink
fix unit test
Browse files Browse the repository at this point in the history
Signed-off-by: Vedant Mahabaleshwarkar <[email protected]>
  • Loading branch information
VedantMahabaleshwarkar committed Nov 12, 2024
1 parent 57543a8 commit 1b26421
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2532,6 +2532,7 @@ var _ = Describe("v1beta1 inference service controller", func() {
FSGroupChangePolicy: nil,
SeccompProfile: nil,
},
AutomountServiceAccountToken: proto.Bool(false),
},
},
Strategy: appsv1.DeploymentStrategy{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ limitations under the License.
package deployment

import (
"k8s.io/client-go/kubernetes"
"strings"
"testing"

Expand All @@ -30,17 +31,20 @@ import (
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
testclient "k8s.io/client-go/kubernetes/fake"
)

func TestCreateDefaultDeployment(t *testing.T) {

type args struct {
clientset kubernetes.Interface
objectMeta metav1.ObjectMeta
workerObjectMeta metav1.ObjectMeta
componentExt *v1beta1.ComponentExtensionSpec
podSpec *corev1.PodSpec
workerPodSpec *corev1.PodSpec
}
clientset := testclient.NewClientset()
testInput := map[string]args{
"defaultDeployment": {
objectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -389,7 +393,7 @@ func TestCreateDefaultDeployment(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := createRawDeployment(tt.args.objectMeta, tt.args.workerObjectMeta, tt.args.componentExt, tt.args.podSpec, tt.args.workerPodSpec)
got := createRawDeployment(clientset, tt.args.objectMeta, tt.args.workerObjectMeta, tt.args.componentExt, tt.args.podSpec, tt.args.workerPodSpec)
for i, deploy := range got {
if diff := cmp.Diff(tt.expected[i], deploy, cmpopts.IgnoreFields(appsv1.Deployment{}, "Spec.Template.Spec.SecurityContext"),
cmpopts.IgnoreFields(appsv1.Deployment{}, "Spec.Template.Spec.RestartPolicy"),
Expand Down Expand Up @@ -457,7 +461,7 @@ func TestCreateDefaultDeployment(t *testing.T) {
ttExpected := getDefaultExpectedDeployment()

// update objectMeta using modify func
got := createRawDeployment(ttArgs.objectMeta, ttArgs.workerObjectMeta, ttArgs.componentExt, tt.modifyArgs(ttArgs).podSpec, tt.modifyArgs(ttArgs).workerPodSpec)
got := createRawDeployment(clientset, ttArgs.objectMeta, ttArgs.workerObjectMeta, ttArgs.componentExt, tt.modifyArgs(ttArgs).podSpec, tt.modifyArgs(ttArgs).workerPodSpec)

// update expected value using modifyExpected func
expected := tt.modifyExpected(ttExpected)
Expand Down Expand Up @@ -760,7 +764,7 @@ func TestCreateDefaultDeployment(t *testing.T) {
ttExpected := getDefaultExpectedDeployment()

// update objectMeta using modify func
got := createRawDeployment(tt.modifyObjectMetaArgs(ttArgs).objectMeta, tt.modifyWorkerObjectMetaArgs(ttArgs).workerObjectMeta, ttArgs.componentExt, tt.modifyPodSpecArgs(ttArgs).podSpec, tt.modifyWorkerPodSpecArgs(ttArgs).workerPodSpec)
got := createRawDeployment(clientset, tt.modifyObjectMetaArgs(ttArgs).objectMeta, tt.modifyWorkerObjectMetaArgs(ttArgs).workerObjectMeta, ttArgs.componentExt, tt.modifyPodSpecArgs(ttArgs).podSpec, tt.modifyWorkerPodSpecArgs(ttArgs).workerPodSpec)

// update expected value using modifyExpected func
expected := tt.modifyExpected(ttExpected)
Expand Down

0 comments on commit 1b26421

Please sign in to comment.