fix(region): hostname for vm and host

This commit is contained in:
Qu Xuan
2021-11-11 15:59:46 +08:00
parent d07702c57f
commit 5b383afd57
41 changed files with 483 additions and 336 deletions

View File

@@ -17,8 +17,6 @@ package stringutils2
import (
"reflect"
"testing"
"yunion.io/x/pkg/util/osprofile"
)
func TestEscapeString(t *testing.T) {
@@ -123,50 +121,6 @@ func TestEscapeEchoString(t *testing.T) {
}
}
func TestGenerateHostName(t *testing.T) {
type input struct {
name string
osType string
hostName string
}
for _, pair := range []input{
input{
name: "--test-host-name.......",
hostName: "test-host-name",
},
input{
name: "--test-host-1234567890-name.......",
osType: osprofile.OS_TYPE_WINDOWS,
hostName: "test-host-12345",
},
input{
name: "--test-host-1234-67890-name.......",
osType: osprofile.OS_TYPE_WINDOWS,
hostName: "test-host-1234",
},
input{
name: "1234567890123456",
osType: osprofile.OS_TYPE_WINDOWS,
hostName: "host-1234567890",
},
input{
name: "001234567890123456",
osType: osprofile.OS_TYPE_WINDOWS,
hostName: "host-0012345678",
},
input{
name: "",
hostName: "hostname-for",
},
} {
hostName := GenerateHostName(pair.name, pair.osType)
if hostName != pair.hostName {
t.Fatalf("%s hostName should be %s, current is %s", pair.name, pair.hostName, hostName)
}
}
}
func TestGetCharTypeCount(t *testing.T) {
cases := []struct {
in string