Files
faas-cli/schema/image_test.go
Alex Ellis (VMware) 733313add1 Code review and fix-up for --tag
- Adds --tag=SHA option for build/push/deploy
- Corrects behaviour "tag" was not being honoured from the Docker
tag within the YAML file
- Did not work at all, had major blocking bug causing build to
fail to work by adding -t twice
- Wrote unit tests for new behaviour extracting new methods
- Introduced mode SHA / default and branch - branch-mode is yet to
be implemented
- Added final Docker image name to status updates in build command
- Tested with samples from faas-cli repo using --tag=SHA on/off

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-07-23 10:11:39 +01:00

40 lines
1000 B
Go

package schema
import "testing"
func Test_BuildImageName_DefaultFormat(t *testing.T) {
want := "img:latest"
got := BuildImageName(DefaultFormat, "img", "ef384", "master")
if got != want {
t.Errorf("BuildImageName want: \"%s\", got: \"%s\"", want, got)
}
}
func Test_BuildImageName_SHAFormat(t *testing.T) {
want := "img:latest-ef384"
got := BuildImageName(SHAFormat, "img", "ef384", "master")
if got != want {
t.Errorf("BuildImageName want: \"%s\", got: \"%s\"", want, got)
}
}
func Test_BuildImageName_SHAFormat_WithNumericVersion(t *testing.T) {
want := "img:0.2-ef384"
got := BuildImageName(SHAFormat, "img:0.2", "ef384", "master")
if got != want {
t.Errorf("BuildImageName want: \"%s\", got: \"%s\"", want, got)
}
}
func Test_BuildImageName_BranchAndSHAFormat(t *testing.T) {
want := "img:latest-master-ef384"
got := BuildImageName(BranchAndSHAFormat, "img", "ef384", "master")
if got != want {
t.Errorf("BuildImageName want: \"%s\", got: \"%s\"", want, got)
}
}