fix: baremetal mismatch with empty Guid

This commit is contained in:
Qiu Jian
2022-01-22 18:50:58 +08:00
parent bd914db5a6
commit 072beffe2f
6 changed files with 67 additions and 52 deletions
+10
View File
@@ -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
}
+20
View File
@@ -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)
}
}
}