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

test: add unit test for jobset controller #485

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion pkg/controllers/jobset_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client/fake"

jobset "sigs.k8s.io/jobset/api/jobset/v1alpha2"
"sigs.k8s.io/jobset/pkg/constants"
testutils "sigs.k8s.io/jobset/pkg/util/testing"
Expand Down
24 changes: 24 additions & 0 deletions pkg/util/testing/wrappers.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ func (j *JobSetWrapper) SetLabels(labels map[string]string) *JobSetWrapper {
return j
}

// SetConditions sets the value of the jobSet.status conditions.
func (j *JobSetWrapper) SetConditions(conditions []metav1.Condition) *JobSetWrapper {
j.Status.Conditions = conditions
return j
}

// SetGenerateName sets the JobSet name.
func (j *JobSetWrapper) SetGenerateName(namePrefix string) *JobSetWrapper {
// Name and GenerateName are mutually exclusive, so we must unset the Name field.
Expand Down Expand Up @@ -353,6 +359,24 @@ func (j *JobWrapper) Ready(ready int32) *JobWrapper {
return j
}

// DeletionTimestamp sets the job.metadata.deletionTimestamp.
func (j *JobWrapper) DeletionTimestamp(deletionTimestamp *metav1.Time) *JobWrapper {
j.ObjectMeta.DeletionTimestamp = deletionTimestamp
return j
}

// StartTimestamp sets the job.status.startTime.
func (j *JobWrapper) StartTimestamp(startTime *metav1.Time) *JobWrapper {
j.Status.StartTime = startTime
return j
}

// ResourceVersion sets the job.metadata.resourceVersion.
func (j *JobWrapper) ResourceVersion(resourceVersion string) *JobWrapper {
j.ObjectMeta.ResourceVersion = resourceVersion
return j
}

// Tolerations set the tolerations.
func (j *JobWrapper) Tolerations(t []corev1.Toleration) *JobWrapper {
j.Spec.Template.Spec.Tolerations = t
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.