Skip to content

Commit

Permalink
some changes
Browse files Browse the repository at this point in the history
Signed-off-by: Feny Mehta <[email protected]>
  • Loading branch information
fbm3307 committed Nov 7, 2024
1 parent 144dd2c commit 0d80548
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions pkg/cmd/adm/restart_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func TestRestartDeployment(t *testing.T) {
GroupVersion: rolloutGroupVersionEncoder,
NegotiatedSerializer: ns,
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
body := io.NopCloser(bytes.NewReader([]byte(runtime.EncodeOrDie(encoder, deployment1))))
body := io.NopCloser(bytes.NewReader([]byte(runtime.EncodeOrDie(encoder, deployment2))))
return &http.Response{StatusCode: http.StatusOK, Header: cmdtesting.DefaultHeader(), Body: body}, nil
}),
}
Expand All @@ -118,6 +118,16 @@ func TestRestartDeployment(t *testing.T) {
Type: appsv1.DeploymentAvailable,
}},
}
deployment2.Status = appsv1.DeploymentStatus{
Replicas: 1,
UpdatedReplicas: 1,
ReadyReplicas: 1,
AvailableReplicas: 1,
UnavailableReplicas: 0,
Conditions: []appsv1.DeploymentCondition{{
Type: appsv1.DeploymentAvailable,
}},
}
c, err := runtime.DefaultUnstructuredConverter.ToUnstructured(deployment1.DeepCopyObject())
if err != nil {
t.Errorf("unexpected err %s", err)
Expand Down Expand Up @@ -150,7 +160,7 @@ func TestRestartDeployment(t *testing.T) {
require.Contains(t, term.Output(), "Listing the pods to be deleted")
require.Contains(t, term.Output(), "Starting to delete the pods")
actual := &appsv1.Deployment{}
AssertObjectHasContent(t, fakeClient, namespacedName, actual, func() {
AssertObjectHasContent(t, fakeClient, namespacedName1, actual, func() {
require.NotNil(t, actual.Spec.Replicas)
assert.Equal(t, int32(1), *actual.Spec.Replicas)
require.NotNil(t, actual.Annotations["restartedAt"])
Expand All @@ -164,9 +174,10 @@ func TestRestartDeployment(t *testing.T) {
require.Contains(t, term.Output(), "Checking the status of the rolled out deployment")
require.Contains(t, term.Output(), "Running the Rollout status to check the status of the deployment")
} else if tc.labelValue == "codeready-toolchain" {
require.Error(t, err)
require.Error(t, err, "no operator based deployment restart happened as operator deployment found in namespace")
} else if tc.labelValue == "kubesaw-controller-manager" {
require.Contains(t, term.Output(), "No Non-operator deployment restart happened as Non-Operator deployment found in namespace")
assert.Equal(t, 1, cscalls)
}

})
Expand Down

0 comments on commit 0d80548

Please sign in to comment.