Skip to content

Commit

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

Signed-off-by: David Gageot <david@gageot.net>
  • Loading branch information
dgageot committed Feb 8, 2019
1 parent 5862895 commit 74496ec
Show file tree
Hide file tree
Showing 13 changed files with 75 additions and 2 deletions.
14 changes: 12 additions & 2 deletions integration/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,22 @@ 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"

out, err := util.RunCmdOut(buildCmd)
if err != nil {
t.Fatalf("testing error: %v, %s", err, out)
}
}

func TestListConfig(t *testing.T) {
baseConfig := &config.Config{
Global: &config.ContextConfig{
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: targets

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

# Providing another target
# Would have caught #1605
- image: target2
context: targets
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
9 changes: 9 additions & 0 deletions integration/testdata/build/targets/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM busybox as target1

COPY file1 file2 /data/
RUN [ "$(find /data -type f | wc -l | xargs)" == "2" ]

FROM busybox as target2

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

0 comments on commit 74496ec

Please sign in to comment.