Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion core/asset/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -15,6 +17,8 @@ var AllSupportedTypes = []Type{
TypeDashboard,
TypeTopic,
TypeFeatureTable,
TypeApplication,
TypeModel,
}

// Type specifies a supported type name
Expand All @@ -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
Expand Down
59 changes: 25 additions & 34 deletions core/asset/type_test.go
Original file line number Diff line number Diff line change
@@ -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)
}
}
8 changes: 8 additions & 0 deletions internal/server/v1beta1/type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ func TestGetTypes(t *testing.T) {
Name: "feature_table",
Count: 0,
},
{
Name: "application",
Count: 0,
},
{
Name: "model",
Count: 0,
},
},
}

Expand Down