feat: Support model code generation for multi tables (#1836)
* Support model code generation for multi tables * Format code * Format code Co-authored-by: anqiansong <anqiansong@bytedance.com>
This commit is contained in:
@@ -5,6 +5,8 @@ import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -86,3 +88,30 @@ func TestFromDDl(t *testing.T) {
|
||||
_ = os.Remove(filename)
|
||||
fromDDL("1gozero")
|
||||
}
|
||||
|
||||
func Test_parseTableList(t *testing.T) {
|
||||
testData := []string{"foo", "b*", "bar", "back_up", "foo,bar,b*"}
|
||||
patterns := parseTableList(testData)
|
||||
actual := patterns.list()
|
||||
expected := []string{"foo", "b*", "bar", "back_up"}
|
||||
sort.Slice(actual, func(i, j int) bool {
|
||||
return actual[i] > actual[j]
|
||||
})
|
||||
sort.Slice(expected, func(i, j int) bool {
|
||||
return expected[i] > expected[j]
|
||||
})
|
||||
assert.Equal(t, strings.Join(expected, ","), strings.Join(actual, ","))
|
||||
|
||||
matchTestData := map[string]bool{
|
||||
"foo": true,
|
||||
"bar": true,
|
||||
"back_up": true,
|
||||
"bit": true,
|
||||
"ab": false,
|
||||
"b": true,
|
||||
}
|
||||
for v, expected := range matchTestData {
|
||||
actual := patterns.Match(v)
|
||||
assert.Equal(t, expected, actual)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user