Skip to content

Commit

Permalink
Merge pull request #19681 from GeoBK/chore/mkpj/refactor-tests
Browse files Browse the repository at this point in the history
mkpj: Refactor trigger_test.go
  • Loading branch information
k8s-ci-robot committed Oct 26, 2020
2 parents 913cb1d + 01838d2 commit 0b8569d
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions prow/pjutil/trigger_test.go
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package pjutil

import (
"fmt"
"reflect"
"testing"

Expand All @@ -28,15 +29,10 @@ import (
"k8s.io/test-infra/prow/client/clientset/versioned/fake"
)

type fakeJobResult struct {
err error
}

func Test_resultForJob(t *testing.T) {
type args struct {
pj prowapi.ProwJob
watchResults []prowapi.ProwJob
selector string
}
testcases := []struct {
name string
Expand Down Expand Up @@ -74,7 +70,6 @@ func Test_resultForJob(t *testing.T) {
},
},
},
selector: "metadata.name=winwin",
},
expected: pjapi.ProwJobStatus{
State: prowapi.SuccessState,
Expand Down Expand Up @@ -122,7 +117,6 @@ func Test_resultForJob(t *testing.T) {
},
},
},
selector: "metadata.name=winwin",
},
expected: pjapi.ProwJobStatus{
State: prowapi.SuccessState,
Expand Down Expand Up @@ -158,7 +152,6 @@ func Test_resultForJob(t *testing.T) {
},
},
},
selector: "metadata.name=winwin",
},
expected: pjapi.ProwJobStatus{
State: prowapi.FailureState,
Expand All @@ -176,7 +169,7 @@ func Test_resultForJob(t *testing.T) {
}
return true, ret, nil
})
pjr, shouldContinue, err := resultForJob(cs.ProwV1().ProwJobs("prowjobs"), tc.args.selector)
pjr, shouldContinue, err := resultForJob(cs.ProwV1().ProwJobs("prowjobs"), fmt.Sprintf("metadata.name=%s", tc.args.pj.Name))
if !reflect.DeepEqual(pjr.State, tc.expected.State) {
t.Errorf("resultForJob() ProwJobStatus got = %v, want %v", pjr, tc.expected)
}
Expand Down

0 comments on commit 0b8569d

Please sign in to comment.