54 lines
1.0 KiB
Go
54 lines
1.0 KiB
Go
package platform_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/influxdata/platform"
|
|
platformtesting "github.com/influxdata/platform/testing"
|
|
)
|
|
|
|
func TestLabelValidate(t *testing.T) {
|
|
type fields struct {
|
|
ResourceID platform.ID
|
|
Name string
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
fields fields
|
|
wantErr bool
|
|
}{
|
|
{
|
|
name: "valid label",
|
|
fields: fields{
|
|
ResourceID: platformtesting.MustIDBase16("020f755c3c082000"),
|
|
Name: "iot",
|
|
},
|
|
},
|
|
{
|
|
name: "label requires a resourceid",
|
|
fields: fields{
|
|
Name: "iot",
|
|
},
|
|
wantErr: true,
|
|
},
|
|
{
|
|
name: "label requires a name",
|
|
fields: fields{
|
|
ResourceID: platformtesting.MustIDBase16("020f755c3c082000"),
|
|
},
|
|
wantErr: true,
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
m := platform.Label{
|
|
ResourceID: tt.fields.ResourceID,
|
|
Name: tt.fields.Name,
|
|
}
|
|
if err := m.Validate(); (err != nil) != tt.wantErr {
|
|
t.Errorf("Label.Validate() error = %v, wantErr %v", err, tt.wantErr)
|
|
}
|
|
})
|
|
}
|
|
}
|