Skip to content

Commit

Permalink
fix: zrn panic
Browse files Browse the repository at this point in the history
  • Loading branch information
katallaxie committed Feb 19, 2024
1 parent 715a19f commit 307127c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
2 changes: 0 additions & 2 deletions zrn.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import (
"github.com/go-playground/validator/v10"
)

const charset = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-"

const (
// DefaultSeparator is the default separator used to join the URN segments.
DefaultSeparator = ":"
Expand Down
33 changes: 33 additions & 0 deletions zrn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,36 @@ func TestNew(t *testing.T) {
})
}
}

func TestMust(t *testing.T) {
tests := []struct {
desc string
namespace zrn.Match
partition zrn.Match
product zrn.Match
region zrn.Match
identifier zrn.Match
resource zrn.Match
expected *zrn.ZRN
expectedErr bool
}{
{
desc: "invalid ZRN",
namespace: "",
partition: "vision",
product: "microscopy",
region: "de",
identifier: "foo",
resource: "bar",
expected: nil,
},
}

for _, test := range tests {
t.Run(test.desc, func(t *testing.T) {
assert.Panics(t, func() {
zrn.Must(test.namespace, test.partition, test.product, test.region, test.identifier, test.resource)
})
})
}
}

0 comments on commit 307127c

Please sign in to comment.