Skip to content

Commit

Permalink
Every type of artifact should be handled.
Browse files Browse the repository at this point in the history
If that’s not the case, we want to see it fail
during tests.

Signed-off-by: David Gageot <david@gageot.net>
  • Loading branch information
dgageot committed Oct 7, 2019
1 parent 18721bb commit e264bb7
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 14 deletions.
42 changes: 29 additions & 13 deletions integration/diagnose_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ limitations under the License.
package integration

import (
"io/ioutil"
"path/filepath"
"testing"

"github.com/GoogleContainerTools/skaffold/integration/skaffold"
Expand All @@ -30,20 +32,34 @@ func TestDiagnose(t *testing.T) {
t.Skip("skipping test that is not gcp only")
}

tests := []struct {
name string
dir string
}{
{name: "kaniko builder", dir: "examples/kaniko"},
{name: "docker builder", dir: "examples/nodejs"},
{name: "jib maven builder", dir: "testdata/jib"},
{name: "jib gradle builder", dir: "testdata/jib-gradle"},
{name: "bazel builder", dir: "examples/bazel"},
{name: "custom builder", dir: "testdata/custom"},
examples, err := folders("examples")
if err != nil {
t.Fatal("unable to list examples")
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
skaffold.Diagnose().InDir(test.dir).RunOrFail(t)
if len(examples) == 0 {
t.Fatal("didn't find any example")
}

for _, example := range examples {
t.Run(example, func(t *testing.T) {
skaffold.Diagnose().InDir(filepath.Join("examples", example)).RunOrFail(t)
})
}
}

func folders(root string) ([]string, error) {
var folders []string

files, err := ioutil.ReadDir(root)
if err != nil {
return nil, err
}

for _, f := range files {
if f.Mode().IsDir() {
folders = append(folders, f.Name())
}
}

return folders, err
}
6 changes: 5 additions & 1 deletion pkg/skaffold/runner/diagnose.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,12 @@ func typeOfArtifact(a *latest.Artifact) string {
return "Bazel artifact"
case a.JibArtifact != nil:
return "Jib artifact"
case a.Kaniko != nil:
return "Kaniko artifact"
case a.CustomArtifact != nil:
return "Custom artifact"
default:
return "Unknown artifact"
panic("Unknown artifact")
}
}

Expand Down

0 comments on commit e264bb7

Please sign in to comment.