cosmos-sdk/schema/name_test.go
Aaron Craelius 38c1d6a5d4
refactor(indexer/base): move to cosmossdk.io/schema (#20744)
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2024-06-26 15:46:08 +00:00

32 lines
633 B
Go

package schema
import "testing"
func TestValidateName(t *testing.T) {
tests := []struct {
name string
valid bool
}{
{"", false},
{"a", true},
{"A", true},
{"_", true},
{"abc123_def789", true},
{"0", false},
{"a0", true},
{"a_", true},
{"$a", false},
{"a b", false},
{"pretty_unnecessarily_long_but_valid_name", true},
{"totally_unnecessarily_long_and_invalid_name_sdgkhwersdglkhweriqwery3258", false},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
if ValidateName(test.name) != test.valid {
t.Errorf("expected %v for name %q", test.valid, test.name)
}
})
}
}