mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix: baremetal mismatch with empty Guid
This commit is contained in:
@@ -177,3 +177,13 @@ func GenerateRoleName(roleName string) string {
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
func FilterEmpty(input []string) []string {
|
||||
ret := make([]string, 0)
|
||||
for i := range input {
|
||||
if len(input[i]) > 0 {
|
||||
ret = append(ret, input[i])
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
@@ -191,3 +191,23 @@ func TestRoleName(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterEmpty(t *testing.T) {
|
||||
cases := []struct {
|
||||
input []string
|
||||
want []string
|
||||
}{
|
||||
{
|
||||
input: []string{
|
||||
"",
|
||||
},
|
||||
want: []string{},
|
||||
},
|
||||
}
|
||||
for _, c := range cases {
|
||||
got := FilterEmpty(c.input)
|
||||
if !reflect.DeepEqual(got, c.want) {
|
||||
t.Errorf("want: %#v got: %#v", c.want, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user