2022-03-07 10:37:04 +01:00
|
|
|
package api
|
|
|
|
|
|
|
|
import "testing"
|
|
|
|
|
|
|
|
func TestAliasEvent_Valid(t *testing.T) {
|
|
|
|
type fields struct {
|
|
|
|
Alias string
|
|
|
|
AltAliases []string
|
|
|
|
}
|
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
fields fields
|
|
|
|
want bool
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "empty alias",
|
|
|
|
fields: fields{
|
|
|
|
Alias: "",
|
|
|
|
},
|
|
|
|
want: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "empty alias, invalid alt aliases",
|
|
|
|
fields: fields{
|
2022-03-24 11:03:22 +01:00
|
|
|
Alias: "",
|
|
|
|
AltAliases: []string{"%not:valid.local"},
|
2022-03-07 10:37:04 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "valid alias, invalid alt aliases",
|
|
|
|
fields: fields{
|
2022-03-24 11:03:22 +01:00
|
|
|
Alias: "#valid:test.local",
|
|
|
|
AltAliases: []string{"%not:valid.local"},
|
2022-03-07 10:37:04 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "empty alias, invalid alt aliases",
|
|
|
|
fields: fields{
|
2022-03-24 11:03:22 +01:00
|
|
|
Alias: "",
|
|
|
|
AltAliases: []string{"%not:valid.local"},
|
2022-03-07 10:37:04 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "invalid alias",
|
|
|
|
fields: fields{
|
2022-03-24 11:03:22 +01:00
|
|
|
Alias: "%not:valid.local",
|
|
|
|
AltAliases: []string{},
|
2022-03-07 10:37:04 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
a := AliasEvent{
|
|
|
|
Alias: tt.fields.Alias,
|
|
|
|
AltAliases: tt.fields.AltAliases,
|
|
|
|
}
|
|
|
|
if got := a.Valid(); got != tt.want {
|
|
|
|
t.Errorf("Valid() = %v, want %v", got, tt.want)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|