Skip to content

Commit

Permalink
Test that wantPatch cases actually call PATCH
Browse files Browse the repository at this point in the history
  • Loading branch information
imjasonh authored and tekton-robot committed May 13, 2022
1 parent 29c325c commit 9b4d3fc
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/pod/entrypoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,16 +435,22 @@ func TestUpdateReady(t *testing.T) {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
kubeclient := fakek8s.NewSimpleClientset(&c.pod)
patchCalled := false
kubeclient.PrependReactor("patch", "pods", func(a k8stesting.Action) (bool, runtime.Object, error) {
if !c.wantPatch {
t.Fatal("Pod was patched unexpectedly")
}
patchCalled = true
return false, nil, nil
})
if err := UpdateReady(ctx, kubeclient, c.pod); (err != nil) != c.wantErr {
t.Errorf("UpdateReady (wantErr=%t): %v", c.wantErr, err)
}

if c.wantPatch && !patchCalled {
t.Fatal("Pod was not patched")
}

got, err := kubeclient.CoreV1().Pods(c.pod.Namespace).Get(ctx, c.pod.Name, metav1.GetOptions{})
if err != nil {
t.Errorf("Getting pod %q after update: %v", c.pod.Name, err)
Expand Down

0 comments on commit 9b4d3fc

Please sign in to comment.