Skip to content

Commit

Permalink
fix: uncatched issue of the requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
irainia committed Aug 21, 2024
1 parent 8dc15a8 commit 8de55e9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion core/asset/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var (
errTypeInvalidCharacter = errors.New("type must be combination of alphanumeric and underscores")
)

var invalidTypePattern = regexp.MustCompile(`[^a-zA-Z0-9-]`)
var invalidTypePattern = regexp.MustCompile(`[^a-z0-9_]`)

const (
typeMinLength = 3
Expand Down
13 changes: 10 additions & 3 deletions core/asset/type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,15 @@ func TestRegisterSupportedTypes(t *testing.T) {
expectedErrorMsg: "type length must be 3 to 16 inclusive",
},
{
name: "contains character outside alphanumeric and underscore",
name: "contains character outside lower case alphanumeric and underscore, with exclamation mark",
input: asset.Type("abcd_efgh!"),
expectedErrorMsg: "type must be combination of alphanumeric and underscores",
},
{
name: "contains character outside lower case alphanumeric and underscore, with upper case A",
input: asset.Type("Abcd_efgh"),
expectedErrorMsg: "type must be combination of alphanumeric and underscores",
},
}

for _, tc := range testCases {
Expand Down Expand Up @@ -183,11 +188,13 @@ func TestRegisterSupportedTypes(t *testing.T) {
asset.Type("model"),
asset.Type("query"),
asset.Type("metric"),
asset.Type("dataset"),
asset.Type("fact_source"),
asset.Type("dimension_01a"),
}

inputTypes := []asset.Type{
asset.Type("dataset"),
asset.Type("fact_source"),
asset.Type("dimension_01a"),
}

actualError := asset.RegisterSupportedTypes(inputTypes...)
Expand Down

0 comments on commit 8de55e9

Please sign in to comment.