Simpler test
@@ -21,24 +21,11 @@ import (
"io"
"testing"
+ "github.com/GoogleCloudPlatform/skaffold/pkg/skaffold/util"
"github.com/pkg/errors"
)
-func index(vs []string, t string) int {
- for i, v := range vs {
- if v == t {
- return i
- }
- }
- return -1
-}
-
-func includes(vs []string, t string) bool {
- return index(vs, t) >= 0
-}
-
func TestDockerContext(t *testing.T) {
- t.Run("context excludes dockerignore files", func(t *testing.T) {
reader, writer := io.Pipe()
go func() {
err := CreateDockerTarContext(writer, "Dockerfile", "../../../testdata/docker")
@@ -64,20 +51,19 @@ func TestDockerContext(t *testing.T) {
files = append(files, header.Name)
}
- if includes(files, "ignored.txt") {
+ if util.StrSliceContains(files, "ignored.txt") {
t.Error("File ignored.txt should have been excluded, but was not")
}
- if includes(files, "files/ignored.txt") {
+ if util.StrSliceContains(files, "files/ignored.txt") {
t.Error("File files/ignored.txt should have been excluded, but was not")
}
- if !includes(files, "files/included.txt") {
+ if !util.StrSliceContains(files, "files/included.txt") {
t.Error("File files/included.txt should have been included, but was not")
}
- if !includes(files, "Dockerfile") {
+ if !util.StrSliceContains(files, "Dockerfile") {
t.Error("File Dockerfile should have been included, but was not")
}
- })
}
