Skip to content

Commit

Permalink
Moving structure test's dependency file extraction logic to NewTester…
Browse files Browse the repository at this point in the history
…() to reduce code redundancy.
  • Loading branch information
PriyaModali committed Feb 22, 2021
1 parent 7c2083f commit 5e1d859
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
5 changes: 2 additions & 3 deletions pkg/skaffold/test/test_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,12 @@ type Config interface {
// and returns a Tester instance with all the necessary test runners
// to run all specified tests.
func NewTester(cfg Config, imagesAreLocal func(imageName string) (bool, error)) (Tester, error) {
runner, err := getRunner(cfg, imagesAreLocal, cfg.TestCases())
runner, err := getRunners(cfg, imagesAreLocal, cfg.TestCases())
if err != nil {
return nil, err
}

return FullTester{
// runners: getRunner(cfg, imagesAreLocal, cfg.TestCases()),
runners: runner,
muted: cfg.Muted(),
}, nil
Expand Down Expand Up @@ -113,7 +112,7 @@ func (t FullTester) runTests(ctx context.Context, out io.Writer, bRes []build.Ar
return nil
}

func getRunner(cfg Config, imagesAreLocal func(imageName string) (bool, error), tcs []*latest.TestCase) ([]runner, error) {
func getRunners(cfg Config, imagesAreLocal func(imageName string) (bool, error), tcs []*latest.TestCase) ([]runner, error) {
var runners []runner
for _, tc := range tcs {
if len(tc.StructureTests) != 0 {
Expand Down
19 changes: 10 additions & 9 deletions pkg/skaffold/test/test_factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,18 @@ func TestWrongPattern(t *testing.T) {
}},
}

tester, err := NewTester(cfg, func(imageName string) (bool, error) { return true, nil })
t.CheckNoError(err)

_, err = tester.TestDependencies()
_, err := NewTester(cfg, func(imageName string) (bool, error) { return true, nil })
// t.CheckNoError(err)
t.CheckError(true, err)

err = tester.Test(context.Background(), ioutil.Discard, []build.Artifact{{
ImageName: "image",
Tag: "image:tag",
}})
t.CheckError(true, err)
// _, err = tester.TestDependencies()
// t.CheckError(true, err)

// err = tester.Test(context.Background(), ioutil.Discard, []build.Artifact{{
// ImageName: "image",
// Tag: "image:tag",
// }})
// t.CheckError(true, err)
})
}

Expand Down

0 comments on commit 5e1d859

Please sign in to comment.