Files
go-zero/tools/goctl/api/parser/g4/gen/api/baseparser_test.go
anqiansong 9c2d526a11 Fix unit test (#1730)
Co-authored-by: anqiansong <anqiansong@bytedance.com>
2022-04-01 14:46:12 +08:00

33 lines
606 B
Go

package api
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestMatch(t *testing.T) {
assert.False(t, matchRegex("v1ddd", versionRegex))
}
func TestImportRegex(t *testing.T) {
tests := []struct {
value string
matched bool
}{
{`"bar.api"`, true},
{`"foo/bar.api"`, true},
{`"/foo/bar.api"`, true},
{`"../foo/bar.api"`, true},
{`"../../foo/bar.api"`, true},
{`"//bar.api"`, false},
{`"/foo/foo_bar.api"`, true},
}
for _, tt := range tests {
t.Run(tt.value, func(t *testing.T) {
assert.Equal(t, tt.matched, matchRegex(tt.value, importValueRegex))
})
}
}