diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-05-05 16:47:59 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-05 16:47:59 -0400 |
commit | ed6f399770946bb2e88f8b94e1d2f279208648d4 (patch) | |
tree | 21d94cb2d4d3571952a933ea98cfd6f701c52a2d /pkg/domain/infra/abi/containers_runlabel_test.go | |
parent | db48da4d99a69171c0ae9998ea527e6b31e0c680 (diff) | |
parent | f8846bd17b5c6dacb5908112ec24ce332185e5d1 (diff) | |
download | podman-ed6f399770946bb2e88f8b94e1d2f279208648d4.tar.gz podman-ed6f399770946bb2e88f8b94e1d2f279208648d4.tar.bz2 podman-ed6f399770946bb2e88f8b94e1d2f279208648d4.zip |
Merge pull request #10193 from rhatdan/runlabel
Fix handling of runlabel IMAGE and NAME
Diffstat (limited to 'pkg/domain/infra/abi/containers_runlabel_test.go')
-rw-r--r-- | pkg/domain/infra/abi/containers_runlabel_test.go | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/pkg/domain/infra/abi/containers_runlabel_test.go b/pkg/domain/infra/abi/containers_runlabel_test.go new file mode 100644 index 000000000..10f9ae004 --- /dev/null +++ b/pkg/domain/infra/abi/containers_runlabel_test.go @@ -0,0 +1,40 @@ +package abi + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestReplaceName(t *testing.T) { + tests := [][]string{ + {"NAME=$NAME", "test1", "NAME=test1"}, + {"NAME=${NAME}", "test2", "NAME=test2"}, + {"NAME=NAME", "test3", "NAME=test3"}, + {"NAME=NAMEFOO", "test3", "NAME=NAMEFOO"}, + {"NAME", "test4", "test4"}, + {"FNAME", "test5", "FNAME"}, + {"NAME=foo", "test6", "NAME=foo"}, + {"This is my NAME", "test7", "This is my NAME"}, + } + for _, args := range tests { + val := replaceName(args[0], args[1]) + assert.Equal(t, val, args[2]) + } +} + +func TestReplaceImage(t *testing.T) { + tests := [][]string{ + {"IMAGE=$IMAGE", "test1", "IMAGE=test1"}, + {"IMAGE=${IMAGE}", "test2", "IMAGE=test2"}, + {"IMAGE=IMAGE", "test3", "IMAGE=test3"}, + {"IMAGE=IMAGEFOO", "test3", "IMAGE=IMAGEFOO"}, + {"IMAGE", "test4", "test4"}, + {"FIMAGE", "test5", "FIMAGE"}, + {"IMAGE=foo", "test6", "IMAGE=foo"}, + } + for _, args := range tests { + val := replaceImage(args[0], args[1]) + assert.Equal(t, val, args[2]) + } +} |