Skip to content

Commit

Permalink
Adding a few tests for skaffold build
Browse files Browse the repository at this point in the history
See GoogleContainerTools#441

Signed-off-by: David Gageot <david@gageot.net>
  • Loading branch information
dgageot committed Feb 8, 2019
1 parent 5862895 commit cd6da7b
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 2 deletions.
13 changes: 11 additions & 2 deletions integration/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,17 @@ func TestFix(t *testing.T) {
runCmd := exec.Command("skaffold", "run", "--namespace", ns.Name, "-f", "-")
runCmd.Dir = "testdata/fix"
runCmd.Stdin = bytes.NewReader(out)
err = util.RunCmd(runCmd)
if err != nil {

if err := util.RunCmd(runCmd); err != nil {
t.Fatalf("testing error: %v", err)
}
}

func TestBuild(t *testing.T) {
buildCmd := exec.Command("skaffold", "build")
buildCmd.Dir = "testdata/build"

if err := util.RunCmd(buildCmd); err != nil {
t.Fatalf("testing error: %v", err)
}
}
Expand Down
3 changes: 3 additions & 0 deletions integration/testdata/build/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM busybox

COPY . /data
7 changes: 7 additions & 0 deletions integration/testdata/build/multi-env/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM busybox

ENV file1=file1 \
file2=file2

COPY $file1 $file2 /data/
RUN [ "$(find /data -type f | wc -l | xargs)" == "2" ]
1 change: 1 addition & 0 deletions integration/testdata/build/multi-env/file1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
file1
1 change: 1 addition & 0 deletions integration/testdata/build/multi-env/file2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
file2
33 changes: 33 additions & 0 deletions integration/testdata/build/skaffold.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: skaffold/v1beta5
kind: Config
build:
artifacts:
# A simple Docker build
- image: simple-build

# Building from a sub-directory
- image: sub-directory
context: sub-directory

# Testing multiline env variables in Dockerfiles
# Would have caught #1624
- image: multi-env
context: multi-env

# Testing Dockerfiles with targets
- image: targets
context: target

# Providing a target
# Would have caught #1605
- image: target1
context: target
docker:
target: target1

# Providing another target
# Would have caught #1605
- image: target2
context: target
docker:
target: target2
4 changes: 4 additions & 0 deletions integration/testdata/build/sub-directory/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM busybox

COPY file1 file2 /data/
RUN [ "$(find /data -type f | wc -l | xargs)" == "2" ]
1 change: 1 addition & 0 deletions integration/testdata/build/sub-directory/file1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
file1
1 change: 1 addition & 0 deletions integration/testdata/build/sub-directory/file2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
file2

0 comments on commit cd6da7b

Please sign in to comment.