1234567891011121314151617181920212223242526272829 |
- 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)
- }
|