Skip to content

Commit

Permalink
refactor: change test case name to tests and test names start with lower
Browse files Browse the repository at this point in the history
  • Loading branch information
zhifei92 committed Apr 10, 2024
1 parent 7a36cf7 commit e532cfb
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions pkg/controllers/success_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ func TestJobMatchesSuccessPolicy(t *testing.T) {
ns = "default"
)

jobMatchesSuccessPolicyTestCases := []struct {
tests := []struct {
name string
js *jobset.JobSet
job *batchv1.Job
expected bool
}{
{
name: "TargetReplicatedJobs is empty",
name: "jobset's TargetReplicatedJobs is empty",
js: testutils.MakeJobSet(jobSetName, ns).
SuccessPolicy(&jobset.SuccessPolicy{
TargetReplicatedJobs: []string{},
Expand All @@ -48,7 +48,7 @@ func TestJobMatchesSuccessPolicy(t *testing.T) {
expected: true,
},
{
name: "Job matches one of the TargetReplicatedJobs",
name: "job matches one of the TargetReplicatedJobs",
js: testutils.MakeJobSet(jobSetName, ns).
SuccessPolicy(&jobset.SuccessPolicy{
TargetReplicatedJobs: []string{"test-replicated-job-1", "test-replicated-job-2"},
Expand All @@ -59,7 +59,7 @@ func TestJobMatchesSuccessPolicy(t *testing.T) {
expected: true,
},
{
name: "Job does not match any of the TargetReplicatedJobs",
name: "job does not match any of the TargetReplicatedJobs",
js: testutils.MakeJobSet(jobSetName, ns).
SuccessPolicy(&jobset.SuccessPolicy{
TargetReplicatedJobs: []string{"test-replicated-job-1", "test-replicated-job-2"},
Expand All @@ -71,7 +71,7 @@ func TestJobMatchesSuccessPolicy(t *testing.T) {
},
}

for _, tc := range jobMatchesSuccessPolicyTestCases {
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
actual := jobMatchesSuccessPolicy(tc.js, tc.job)
if diff := cmp.Diff(tc.expected, actual); diff != "" {
Expand All @@ -87,14 +87,14 @@ func TestReplicatedJobMatchesSuccessPolicy(t *testing.T) {
ns = "default"
)

replicatedJobMatchTestCases := []struct {
tests := []struct {
name string
js *jobset.JobSet
replicatedJob jobset.ReplicatedJob
expected bool
}{
{
name: "Empty target replicated jobs",
name: "jobset's TargetReplicatedJobs is empty",
js: testutils.MakeJobSet(jobSetName, ns).
SuccessPolicy(&jobset.SuccessPolicy{
TargetReplicatedJobs: []string{},
Expand All @@ -103,7 +103,7 @@ func TestReplicatedJobMatchesSuccessPolicy(t *testing.T) {
expected: true,
},
{
name: "Matching case",
name: "matching case",
js: testutils.MakeJobSet(jobSetName, ns).
SuccessPolicy(&jobset.SuccessPolicy{
TargetReplicatedJobs: []string{"test-replicated-job-1", "test-replicated-job-2"},
Expand All @@ -112,7 +112,7 @@ func TestReplicatedJobMatchesSuccessPolicy(t *testing.T) {
expected: true,
},
{
name: "Non-matching case",
name: "non-matching case",
js: testutils.MakeJobSet(jobSetName, ns).
SuccessPolicy(&jobset.SuccessPolicy{
TargetReplicatedJobs: []string{"test-replicated-job-1", "test-replicated-job-2"},
Expand All @@ -122,7 +122,7 @@ func TestReplicatedJobMatchesSuccessPolicy(t *testing.T) {
},
}

for _, tc := range replicatedJobMatchTestCases {
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
actual := replicatedJobMatchesSuccessPolicy(tc.js, &tc.replicatedJob)
if diff := cmp.Diff(tc.expected, actual); diff != "" {
Expand All @@ -139,14 +139,14 @@ func TestNumJobsMatchingSuccessPolicy(t *testing.T) {
ns = "default"
)

numJobsMatchTestCases := []struct {
tests := []struct {
name string
js *jobset.JobSet
jobs []*batchv1.Job
expected int
}{
{
name: "One job matches the success policy",
name: "one job matches the success policy",
js: testutils.MakeJobSet(jobSetName, ns).
SuccessPolicy(&jobset.SuccessPolicy{
TargetReplicatedJobs: []string{"test-replicated-job-1", "test-replicated-job-2"},
Expand Down Expand Up @@ -211,7 +211,7 @@ func TestNumJobsMatchingSuccessPolicy(t *testing.T) {
},
}

for _, tc := range numJobsMatchTestCases {
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
actual := numJobsMatchingSuccessPolicy(tc.js, tc.jobs)
if diff := cmp.Diff(tc.expected, actual); diff != "" {
Expand All @@ -227,21 +227,21 @@ func TestNumJobsExpectedToSucceed(t *testing.T) {
ns = "default"
)

numJobsMatchTests := []struct {
tests := []struct {
name string
js *jobset.JobSet
expected int
}{
{
name: "OperatorAny",
name: "any single job matching the jobSelector",
js: testutils.MakeJobSet(jobSetName, ns).
SuccessPolicy(&jobset.SuccessPolicy{
Operator: jobset.OperatorAny,
}).Obj(),
expected: 1,
},
{
name: "OperatorAll - all replicated jobs match success policy",
name: "all replicated jobs match success policy",
js: testutils.MakeJobSet(jobSetName, ns).
SuccessPolicy(&jobset.SuccessPolicy{
Operator: jobset.OperatorAll,
Expand All @@ -256,7 +256,7 @@ func TestNumJobsExpectedToSucceed(t *testing.T) {
expected: 3,
},
{
name: "OperatorAll - some replicated jobs don't match success policy",
name: "some replicated jobs don't match success policy",
js: testutils.MakeJobSet(jobSetName, ns).
SuccessPolicy(&jobset.SuccessPolicy{
Operator: jobset.OperatorAll,
Expand All @@ -272,7 +272,7 @@ func TestNumJobsExpectedToSucceed(t *testing.T) {
},
}

for _, tc := range numJobsMatchTests {
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
actual := numJobsExpectedToSucceed(tc.js)
if diff := cmp.Diff(tc.expected, actual); diff != "" {
Expand Down

0 comments on commit e532cfb

Please sign in to comment.