Add more tests for #776
This commit is contained in:
parent
db12a77e6c
commit
5700de039d
|
|
@ -699,8 +699,8 @@ func Test_correctDockerignoreFileIsUsed(t *testing.T) {
|
||||||
type args struct {
|
type args struct {
|
||||||
dockerfilepath string
|
dockerfilepath string
|
||||||
buildcontext string
|
buildcontext string
|
||||||
excluded string
|
excluded []string
|
||||||
notExcluded string
|
included []string
|
||||||
}
|
}
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
|
|
@ -711,8 +711,8 @@ func Test_correctDockerignoreFileIsUsed(t *testing.T) {
|
||||||
args: args{
|
args: args{
|
||||||
dockerfilepath: "../../integration/dockerfiles/Dockerfile_test_dockerignore_relative",
|
dockerfilepath: "../../integration/dockerfiles/Dockerfile_test_dockerignore_relative",
|
||||||
buildcontext: "../../integration/",
|
buildcontext: "../../integration/",
|
||||||
excluded: "ignore_relative/bar",
|
excluded: []string{"ignore_relative/bar"},
|
||||||
notExcluded: "ignore_relative/foo",
|
included: []string{"ignore_relative/foo", "ignore/bar"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -720,23 +720,28 @@ func Test_correctDockerignoreFileIsUsed(t *testing.T) {
|
||||||
args: args{
|
args: args{
|
||||||
dockerfilepath: "../../integration/dockerfiles/Dockerfile_test_dockerignore",
|
dockerfilepath: "../../integration/dockerfiles/Dockerfile_test_dockerignore",
|
||||||
buildcontext: "../../integration/",
|
buildcontext: "../../integration/",
|
||||||
excluded: "ignore/bar",
|
excluded: []string{"ignore/bar"},
|
||||||
notExcluded: "ignore/foo",
|
included: []string{"ignore/foo", "ignore_relative/bar"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
|
||||||
excluded = nil
|
|
||||||
if err := GetExcludedFiles(tt.args.dockerfilepath, tt.args.buildcontext); err != nil {
|
if err := GetExcludedFiles(tt.args.dockerfilepath, tt.args.buildcontext); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if excl := excludeFile(tt.args.excluded, tt.args.buildcontext); !excl {
|
for _, excl := range tt.args.excluded {
|
||||||
t.Errorf("'%v' not excluded as expected", tt.args.excluded)
|
t.Run(tt.name+" to exclude "+excl, func(t *testing.T) {
|
||||||
}
|
if !excludeFile(excl, tt.args.buildcontext) {
|
||||||
if excl := excludeFile(tt.args.notExcluded, tt.args.buildcontext); excl {
|
t.Errorf("'%v' not excluded", excl)
|
||||||
t.Errorf("'%v' excluded against expectation", tt.args.notExcluded)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
for _, incl := range tt.args.included {
|
||||||
|
t.Run(tt.name+" to include "+incl, func(t *testing.T) {
|
||||||
|
if excludeFile(incl, tt.args.buildcontext) {
|
||||||
|
t.Errorf("'%v' not included", incl)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue