packer-cn/builder/tencentcloud/cvm/image_config_test.go
ZhiQiang Fan 20315155a9 remove image name check in tencentcloud builder
Spinnaker uses packer to create images, but tencentcloud builder
has name check to forbidden special characters such as dot(.) while
it is absolutely valid in API side.

This patch simply removes this limitation.
2019-06-23 20:32:13 +08:00

36 lines
738 B
Go

package cvm
import "testing"
func TestTencentCloudImageConfig_Prepare(t *testing.T) {
cf := &TencentCloudImageConfig{
ImageName: "foo",
}
if err := cf.Prepare(nil); err != nil {
t.Fatalf("shouldn't have err: %v", err)
}
cf.ImageName = "foo.:"
if err := cf.Prepare(nil); err != nil {
t.Fatal("shouldn't have error")
}
cf.ImageName = "foo"
cf.ImageCopyRegions = []string{"ap-guangzhou", "ap-hongkong"}
if err := cf.Prepare(nil); err != nil {
t.Fatalf("shouldn't have err: %v", err)
}
cf.ImageCopyRegions = []string{"unknown"}
if err := cf.Prepare(nil); err == nil {
t.Fatal("should have err")
}
cf.SkipValidation = true
if err := cf.Prepare(nil); err != nil {
t.Fatalf("shouldn't have err:%v", err)
}
}