diff --git a/core/asset/type.go b/core/asset/type.go index ea78f2c2..6875df74 100644 --- a/core/asset/type.go +++ b/core/asset/type.go @@ -9,6 +9,7 @@ const ( TypeApplication Type = "application" TypeModel Type = "model" TypeQuery Type = "query" + TypeMetric Type = "metric" ) // AllSupportedTypes holds a list of all supported types struct @@ -21,6 +22,7 @@ var AllSupportedTypes = []Type{ TypeApplication, TypeModel, TypeQuery, + TypeMetric, } // Type specifies a supported type name @@ -33,10 +35,10 @@ 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, TypeApplication, TypeModel, TypeQuery: - return true + for _, supportedType := range AllSupportedTypes { + if t == supportedType { + return true + } } return false } diff --git a/core/asset/type_test.go b/core/asset/type_test.go index 1034e53c..816e7a36 100644 --- a/core/asset/type_test.go +++ b/core/asset/type_test.go @@ -16,6 +16,7 @@ func TestTypeString(t *testing.T) { TypeApplication: "application", TypeModel: "model", TypeQuery: "query", + TypeMetric: "metric", } { t.Run((string)(typ), func(t *testing.T) { assert.Equal(t, expected, typ.String()) @@ -24,9 +25,7 @@ func TestTypeString(t *testing.T) { } func TestTypeIsValid(t *testing.T) { - for _, typ := range []Type{ - "dashboard", "job", "table", "topic", "feature_table", "application", "model", "query", - } { + for _, typ := range AllSupportedTypes { t.Run((string)(typ), func(t *testing.T) { assert.Truef(t, typ.IsValid(), "%s should be valid", typ) }) diff --git a/internal/server/v1beta1/type_test.go b/internal/server/v1beta1/type_test.go index 8619d553..8e2a6d51 100644 --- a/internal/server/v1beta1/type_test.go +++ b/internal/server/v1beta1/type_test.go @@ -90,6 +90,10 @@ func TestGetTypes(t *testing.T) { Name: "query", Count: 0, }, + { + Name: "metric", + Count: 0, + }, }, }