Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a few tests for skaffold build #1628

Merged
merged 1 commit into from
Feb 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
35 changes: 35 additions & 0 deletions integration/testdata/build/skaffold.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
apiVersion: skaffold/v1beta5
kind: Config
build:
local:
push: false
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