fix(protoc): only use regular version

Signed-off-by: storyicon <yuanchao@bilibili.com>
This commit is contained in:
storyicon 2021-08-28 19:14:45 +08:00
parent 8bdd192681
commit ef9cf8a802
No known key found for this signature in database
GPG key ID: 245915D985F966CF
3 changed files with 66 additions and 3 deletions

View file

@ -120,3 +120,50 @@ func TestSortSemanticVersion(t *testing.T) {
})
}
}
func TestIsRegularVersion(t *testing.T) {
type args struct {
s string
}
tests := []struct {
name string
args args
want bool
}{
{
args: args{"v0.0.0"},
want: true,
},
{
args: args{"v11.0.0"},
want: true,
},
{
args: args{"v0.11.0"},
want: true,
},
{
args: args{"v0.0.11"},
want: true,
},
{
args: args{"0.0.11"},
want: false,
},
{
args: args{"0.0.a"},
want: false,
},
{
args: args{"v0.0.1-rc0"},
want: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := IsRegularVersion(tt.args.s); got != tt.want {
t.Errorf("IsRegularVersion() = %v, want %v", got, tt.want)
}
})
}
}