Skip to content

Commit

Permalink
feat(type): add support for metric asset
Browse files Browse the repository at this point in the history
  • Loading branch information
haveiss committed Apr 25, 2024
1 parent 4c73dc8 commit ef23256
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
10 changes: 6 additions & 4 deletions core/asset/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -21,6 +22,7 @@ var AllSupportedTypes = []Type{
TypeApplication,
TypeModel,
TypeQuery,
TypeMetric,
}

// Type specifies a supported type name
Expand All @@ -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
}
5 changes: 2 additions & 3 deletions core/asset/type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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)
})
Expand Down
4 changes: 4 additions & 0 deletions internal/server/v1beta1/type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ func TestGetTypes(t *testing.T) {
Name: "query",
Count: 0,
},
{
Name: "metric",
Count: 0,
},
},
}

Expand Down

0 comments on commit ef23256

Please sign in to comment.