Files
kaniko/pkg/commands/volume_test.go
T
dlorenc 9a0e29c441 Refactor the build loop. (#385)
This change refactors the build loop a bit to make cache optimization easier in the future. Some notable changes:

The special casing around volume snapshots is removed. Every volume is added to the snapshotFiles list for every command that will snapshot anyway.
Snapshot saving was extracted to a sub-function
The decision on whether or not to snapshot was extracted
2018-10-09 12:15:17 -05:00

57 lines
1.4 KiB
Go

/*
Copyright 2018 Google LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package commands
import (
"testing"
"github.com/GoogleContainerTools/kaniko/pkg/dockerfile"
"github.com/GoogleContainerTools/kaniko/testutil"
"github.com/google/go-containerregistry/pkg/v1"
"github.com/moby/buildkit/frontend/dockerfile/instructions"
)
func TestUpdateVolume(t *testing.T) {
cfg := &v1.Config{
Env: []string{
"VOLUME=/etc",
},
Volumes: map[string]struct{}{},
}
volumes := []string{
"/tmp",
"/var/lib",
"$VOLUME",
}
volumeCmd := &VolumeCommand{
cmd: &instructions.VolumeCommand{
Volumes: volumes,
},
}
expectedVolumes := map[string]struct{}{
"/tmp": {},
"/var/lib": {},
"/etc": {},
}
buildArgs := dockerfile.NewBuildArgs([]string{})
err := volumeCmd.ExecuteCommand(cfg, buildArgs)
testutil.CheckErrorAndDeepEqual(t, false, err, expectedVolumes, cfg.Volumes)
}