mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-25 02:08:44 +08:00
c9494c8bc7
* model support globbing patterns * optimize model * optimize model * format code
30 lines
851 B
Go
30 lines
851 B
Go
package util
|
|
|
|
import (
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestMatchFiles(t *testing.T) {
|
|
dir, err := filepath.Abs("./")
|
|
assert.Nil(t, err)
|
|
|
|
files, err := MatchFiles("./*.sql")
|
|
assert.Nil(t, err)
|
|
assert.Equal(t, []string{filepath.Join(dir, "studeat.sql"), filepath.Join(dir, "student.sql"), filepath.Join(dir, "xx.sql")}, files)
|
|
|
|
files, err = MatchFiles("./??.sql")
|
|
assert.Nil(t, err)
|
|
assert.Equal(t, []string{filepath.Join(dir, "xx.sql")}, files)
|
|
|
|
files, err = MatchFiles("./*.sq*")
|
|
assert.Nil(t, err)
|
|
assert.Equal(t, []string{filepath.Join(dir, "studeat.sql"), filepath.Join(dir, "student.sql"), filepath.Join(dir, "xx.sql"), filepath.Join(dir, "xx.sql1")}, files)
|
|
|
|
files, err = MatchFiles("./student.sql")
|
|
assert.Nil(t, err)
|
|
assert.Equal(t, []string{filepath.Join(dir, "student.sql")}, files)
|
|
}
|