Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure required PVC is created in reconciler test 👶 #1482

Merged
merged 1 commit into from
Oct 31, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions pkg/reconciler/pipelinerun/pipelinerun_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,9 @@ func TestReconcile(t *testing.T) {
if _, exists := reconciledRun.Status.TaskRuns["test-pipeline-run-success-unit-test-cluster-task-78c5n"]; !exists {
t.Errorf("Expected PipelineRun status to include TaskRun status but was %v", reconciledRun.Status.TaskRuns)
}

// A PVC should have been created to deal with output -> input linking
ensurePVCCreated(t, clients, expectedTaskRun.GetPipelineRunPVCName(), "foo")
}

func TestReconcile_InvalidPipelineRuns(t *testing.T) {
Expand Down Expand Up @@ -1588,3 +1591,20 @@ func makeExpectedTr(condName, ccName string) *v1alpha1.TaskRun {
),
)
}

func ensurePVCCreated(t *testing.T, clients test.Clients, name, namespace string) {
t.Helper()
_, err := clients.Kube.CoreV1().PersistentVolumeClaims(namespace).Get(name, metav1.GetOptions{})
if err != nil {
t.Errorf("Expected PVC %s to be created for VolumeResource but did not exist", name)
}
pvcCreated := false
for _, a := range clients.Kube.Actions() {
if a.GetVerb() == "create" && a.GetResource().Resource == "persistentvolumeclaims" {
pvcCreated = true
}
}
if !pvcCreated {
t.Errorf("Expected to see volume resource PVC created but didn't")
}
}