diff --git a/core/asset/type.go b/core/asset/type.go index f0d23743..44d17af4 100644 --- a/core/asset/type.go +++ b/core/asset/type.go @@ -6,6 +6,8 @@ const ( TypeDashboard Type = "dashboard" TypeTopic Type = "topic" TypeFeatureTable Type = "feature_table" + TypeApplication Type = "application" + TypeModel Type = "model" ) // AllSupportedTypes holds a list of all supported types struct @@ -15,6 +17,8 @@ var AllSupportedTypes = []Type{ TypeDashboard, TypeTopic, TypeFeatureTable, + TypeApplication, + TypeModel, } // Type specifies a supported type name @@ -28,7 +32,8 @@ func (t Type) String() string { // IsValid will validate whether the typename is valid or not func (t Type) IsValid() bool { switch t { - case TypeTable, TypeJob, TypeDashboard, TypeTopic, TypeFeatureTable: + case TypeTable, TypeJob, TypeDashboard, TypeTopic, + TypeFeatureTable, TypeApplication, TypeModel: return true } return false diff --git a/core/asset/type_test.go b/core/asset/type_test.go index b8bbfefa..751637fb 100644 --- a/core/asset/type_test.go +++ b/core/asset/type_test.go @@ -1,46 +1,37 @@ package asset -import "testing" +import ( + "testing" + + "github.com/stretchr/testify/assert" +) func TestTypeString(t *testing.T) { - stringVal := TypeDashboard.String() - if stringVal != "dashboard" { - t.Fatalf("type dashboard converted to %s instead of 'dashboard'", stringVal) - } - stringVal = TypeJob.String() - if stringVal != "job" { - t.Fatalf("type job converted to %s instead of 'job'", stringVal) - } - stringVal = TypeTable.String() - if stringVal != "table" { - t.Fatalf("type table converted to %s instead of 'table'", stringVal) - } - stringVal = TypeTopic.String() - if stringVal != "topic" { - t.Fatalf("type topic converted to %s instead of 'topic'", stringVal) + for typ, expected := range map[Type]string{ + TypeDashboard: "dashboard", + TypeJob: "job", + TypeTable: "table", + TypeTopic: "topic", + TypeFeatureTable: "feature_table", + TypeApplication: "application", + TypeModel: "model", + } { + t.Run((string)(typ), func(t *testing.T) { + assert.Equal(t, expected, typ.String()) + }) } } func TestTypeIsValid(t *testing.T) { - aType := Type("dashboard") - if !aType.IsValid() { - t.Fatalf("type %s is not valid", aType) - } - aType = Type("job") - if !aType.IsValid() { - t.Fatalf("type %s is not valid", aType) - } - aType = Type("table") - if !aType.IsValid() { - t.Fatalf("type %s is not valid", aType) - } - aType = Type("topic") - if !aType.IsValid() { - t.Fatalf("type %s is not valid", aType) + for _, typ := range []Type{ + "dashboard", "job", "table", "topic", "feature_table", "application", "model", + } { + t.Run((string)(typ), func(t *testing.T) { + assert.Truef(t, typ.IsValid(), "%s should be valid", typ) + }) } - aType = Type("random") - if aType.IsValid() { - t.Fatalf("type %s should not be valid", aType) + if typ := Type("random"); typ.IsValid() { + t.Fatalf("type %s should not be valid", typ) } } diff --git a/internal/server/v1beta1/type_test.go b/internal/server/v1beta1/type_test.go index 1fb022f3..dc8db380 100644 --- a/internal/server/v1beta1/type_test.go +++ b/internal/server/v1beta1/type_test.go @@ -78,6 +78,14 @@ func TestGetTypes(t *testing.T) { Name: "feature_table", Count: 0, }, + { + Name: "application", + Count: 0, + }, + { + Name: "model", + Count: 0, + }, }, }