Skip to content

Remove annoying testdata folder #614

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

Merged
merged 1 commit into from
May 30, 2018
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
54 changes: 32 additions & 22 deletions pkg/skaffold/build/local_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"context"
"fmt"
"io"
"io/ioutil"
"path/filepath"
"testing"

"github.com/GoogleContainerTools/skaffold/pkg/skaffold/build/tag"
Expand All @@ -47,22 +49,6 @@ func (t testAuthHelper) GetAuthConfig(string) (types.AuthConfig, error) {
}
func (t testAuthHelper) GetAllAuthConfigs() (map[string]types.AuthConfig, error) { return nil, nil }

var testImage1 = &v1alpha2.Artifact{
ImageName: "gcr.io/test/image",
Workspace: "../../../testdata/docker",
ArtifactType: v1alpha2.ArtifactType{
DockerArtifact: &v1alpha2.DockerArtifact{},
},
}

var testImage2 = &v1alpha2.Artifact{
ImageName: "gcr.io/test/image2",
Workspace: "../../../testdata/docker",
ArtifactType: v1alpha2.ArtifactType{
DockerArtifact: &v1alpha2.DockerArtifact{},
},
}

func TestLocalRun(t *testing.T) {
defer func(h docker.AuthConfigHelper) { docker.DefaultAuthHelper = h }(docker.DefaultAuthHelper)
docker.DefaultAuthHelper = testAuthHelper{}
Expand All @@ -71,6 +57,12 @@ func TestLocalRun(t *testing.T) {
// present on the host
unsetEnvs := testutil.SetEnvs(t, map[string]string{"KUBECONFIG": "badpath"})
defer unsetEnvs(t)

tmp, cleanup := testutil.TempDir(t)
defer cleanup()

ioutil.WriteFile(filepath.Join(tmp, "Dockerfile"), []byte(""), 0640)

var tests = []struct {
description string
config *v1alpha2.BuildConfig
Expand All @@ -87,7 +79,13 @@ func TestLocalRun(t *testing.T) {
out: &bytes.Buffer{},
config: &v1alpha2.BuildConfig{
Artifacts: []*v1alpha2.Artifact{
testImage1,
{
ImageName: "gcr.io/test/image",
Workspace: tmp,
ArtifactType: v1alpha2.ArtifactType{
DockerArtifact: &v1alpha2.DockerArtifact{},
},
},
},
BuildType: v1alpha2.BuildType{
LocalBuild: &v1alpha2.LocalBuild{
Expand All @@ -101,7 +99,13 @@ func TestLocalRun(t *testing.T) {
{
ImageName: "gcr.io/test/image",
Tag: "gcr.io/test/image:imageid",
Artifact: testImage1,
Artifact: &v1alpha2.Artifact{
ImageName: "gcr.io/test/image",
Workspace: tmp,
ArtifactType: v1alpha2.ArtifactType{
DockerArtifact: &v1alpha2.DockerArtifact{},
},
},
},
},
},
Expand All @@ -112,14 +116,14 @@ func TestLocalRun(t *testing.T) {
Artifacts: []*v1alpha2.Artifact{
{
ImageName: "gcr.io/test/image",
Workspace: "../../../testdata/docker",
Workspace: tmp,
ArtifactType: v1alpha2.ArtifactType{
DockerArtifact: &v1alpha2.DockerArtifact{},
},
},
{
ImageName: "gcr.io/test/image2",
Workspace: "../../../testdata/docker",
Workspace: tmp,
ArtifactType: v1alpha2.ArtifactType{
DockerArtifact: &v1alpha2.DockerArtifact{},
},
Expand All @@ -135,7 +139,7 @@ func TestLocalRun(t *testing.T) {
artifacts: []*v1alpha2.Artifact{
{
ImageName: "gcr.io/test/image",
Workspace: "../../../testdata/docker",
Workspace: tmp,
ArtifactType: v1alpha2.ArtifactType{
DockerArtifact: &v1alpha2.DockerArtifact{},
},
Expand All @@ -146,7 +150,13 @@ func TestLocalRun(t *testing.T) {
{
ImageName: "gcr.io/test/image",
Tag: "gcr.io/test/image:imageid",
Artifact: testImage1,
Artifact: &v1alpha2.Artifact{
ImageName: "gcr.io/test/image",
Workspace: tmp,
ArtifactType: v1alpha2.ArtifactType{
DockerArtifact: &v1alpha2.DockerArtifact{},
},
},
},
},
},
Expand Down
1 change: 0 additions & 1 deletion pkg/skaffold/docker/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ func TestRunBuild(t *testing.T) {
api := testutil.NewFakeImageAPIClient(test.tagToImageID, test.testOpts)
err := RunBuild(context.Background(), api, &BuildOptions{
Dockerfile: "Dockerfile",
ContextDir: "../../../testdata/docker",
ImageName: "finalimage",
})
testutil.CheckError(t, test.shouldErr, err)
Expand Down
1 change: 0 additions & 1 deletion testdata/docker/.dockerignore

This file was deleted.

2 changes: 0 additions & 2 deletions testdata/docker/Dockerfile

This file was deleted.

Empty file removed testdata/docker/files/ignored.txt
Empty file.
Empty file removed testdata/docker/files/included.txt
Empty file.
Empty file removed testdata/docker/ignored.txt
Empty file.