forked from containers/podman
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request containers#10193 from rhatdan/runlabel
Fix handling of runlabel IMAGE and NAME
- Loading branch information
Showing
2 changed files
with
57 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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]) | ||
} | ||
} |