util: add test to RegistryMirror option

Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
This commit is contained in:
Yoan Blanc 2019-10-25 13:07:03 +02:00
parent 3873aa05e3
commit 235fc4a61f
No known key found for this signature in database
GPG Key ID: 6058CF4574298812
1 changed files with 15 additions and 0 deletions

View File

@ -60,6 +60,7 @@ func Test_StandardImage(t *testing.T) {
}, &config.KanikoOptions{})
testutil.CheckErrorAndDeepEqual(t, false, err, nil, actual)
}
func Test_ScratchImage(t *testing.T) {
stages, err := parse(dockerfile)
if err != nil {
@ -93,6 +94,20 @@ func Test_TarImage(t *testing.T) {
testutil.CheckErrorAndDeepEqual(t, false, err, nil, actual)
}
func Test_ScratchImageFromMirror(t *testing.T) {
stages, err := parse(dockerfile)
if err != nil {
t.Error(err)
}
actual, err := RetrieveSourceImage(config.KanikoStage{
Stage: stages[1],
}, &config.KanikoOptions{
RegistryMirror: "https://mirrors.gcr.io",
})
expected := empty.Image
testutil.CheckErrorAndDeepEqual(t, false, err, expected, actual)
}
// parse parses the contents of a Dockerfile and returns a list of commands
func parse(s string) ([]instructions.Stage, error) {
p, err := parser.Parse(bytes.NewReader([]byte(s)))