Skip to content

Commit ccafc94

Browse files
authored
feat(type): add support for metric asset (#73)
1 parent 4c73dc8 commit ccafc94

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

core/asset/type.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const (
99
TypeApplication Type = "application"
1010
TypeModel Type = "model"
1111
TypeQuery Type = "query"
12+
TypeMetric Type = "metric"
1213
)
1314

1415
// AllSupportedTypes holds a list of all supported types struct
@@ -21,6 +22,7 @@ var AllSupportedTypes = []Type{
2122
TypeApplication,
2223
TypeModel,
2324
TypeQuery,
25+
TypeMetric,
2426
}
2527

2628
// Type specifies a supported type name
@@ -33,10 +35,10 @@ func (t Type) String() string {
3335

3436
// IsValid will validate whether the typename is valid or not
3537
func (t Type) IsValid() bool {
36-
switch t {
37-
case TypeTable, TypeJob, TypeDashboard, TypeTopic,
38-
TypeFeatureTable, TypeApplication, TypeModel, TypeQuery:
39-
return true
38+
for _, supportedType := range AllSupportedTypes {
39+
if t == supportedType {
40+
return true
41+
}
4042
}
4143
return false
4244
}

core/asset/type_test.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ func TestTypeString(t *testing.T) {
1616
TypeApplication: "application",
1717
TypeModel: "model",
1818
TypeQuery: "query",
19+
TypeMetric: "metric",
1920
} {
2021
t.Run((string)(typ), func(t *testing.T) {
2122
assert.Equal(t, expected, typ.String())
@@ -24,9 +25,7 @@ func TestTypeString(t *testing.T) {
2425
}
2526

2627
func TestTypeIsValid(t *testing.T) {
27-
for _, typ := range []Type{
28-
"dashboard", "job", "table", "topic", "feature_table", "application", "model", "query",
29-
} {
28+
for _, typ := range AllSupportedTypes {
3029
t.Run((string)(typ), func(t *testing.T) {
3130
assert.Truef(t, typ.IsValid(), "%s should be valid", typ)
3231
})

internal/server/v1beta1/type_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ func TestGetTypes(t *testing.T) {
9090
Name: "query",
9191
Count: 0,
9292
},
93+
{
94+
Name: "metric",
95+
Count: 0,
96+
},
9397
},
9498
}
9599

0 commit comments

Comments
 (0)