Update module go-testfixtures/testfixtures/v3 to v3.2.0 (#505)
Update module go-testfixtures/testfixtures/v3 to v3.2.0 Reviewed-on: https://kolaente.dev/vikunja/api/pulls/505
This commit is contained in:
7
vendor/github.com/go-testfixtures/testfixtures/v3/CHANGELOG.md
generated
vendored
7
vendor/github.com/go-testfixtures/testfixtures/v3/CHANGELOG.md
generated
vendored
@ -1,9 +1,14 @@
|
||||
# Changelog
|
||||
|
||||
## v3.2.0 - 2020-05-10
|
||||
|
||||
- Add support for loading multiple files and directories
|
||||
([#65](https://github.com/go-testfixtures/testfixtures/pull/65)).
|
||||
|
||||
## v3.1.2 - 2020-04-26
|
||||
|
||||
- Dump: Fix column order in generated YAML files
|
||||
[#62](https://github.com/go-testfixtures/testfixtures/pull/62)
|
||||
([#62](https://github.com/go-testfixtures/testfixtures/pull/62)).
|
||||
|
||||
## v3.1.1 - 2020-01-11
|
||||
|
||||
|
19
vendor/github.com/go-testfixtures/testfixtures/v3/README.md
generated
vendored
19
vendor/github.com/go-testfixtures/testfixtures/v3/README.md
generated
vendored
@ -192,6 +192,25 @@ if err != nil {
|
||||
}
|
||||
```
|
||||
|
||||
With `Paths` option, you can specify the paths that fixtures will load
|
||||
from. Path can be directory or file. If directory, we will search YAML files
|
||||
in it.
|
||||
|
||||
```go
|
||||
fixtures, err := testfixtures.New(
|
||||
testfixtures.Database(db),
|
||||
testfixtures.Dialect("postgres"),
|
||||
testfixtures.Paths(
|
||||
"fixtures/orders.yml",
|
||||
"fixtures/customers.yml",
|
||||
"common_fixtures/users"
|
||||
),
|
||||
)
|
||||
if err != nil {
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
## Security check
|
||||
|
||||
In order to prevent you from accidentally wiping the wrong database, this
|
||||
|
45
vendor/github.com/go-testfixtures/testfixtures/v3/testfixtures.go
generated
vendored
45
vendor/github.com/go-testfixtures/testfixtures/v3/testfixtures.go
generated
vendored
@ -5,6 +5,7 @@ import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
@ -185,7 +186,7 @@ func Directory(dir string) func(*Loader) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
l.fixturesFiles = fixtures
|
||||
l.fixturesFiles = append(l.fixturesFiles, fixtures...)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@ -197,7 +198,19 @@ func Files(files ...string) func(*Loader) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
l.fixturesFiles = fixtures
|
||||
l.fixturesFiles = append(l.fixturesFiles, fixtures...)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// Paths inform Loader to load a given set of YAML files and directories.
|
||||
func Paths(paths ...string) func(*Loader) error {
|
||||
return func(l *Loader) error {
|
||||
fixtures, err := l.fixturesFromPaths(paths...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
l.fixturesFiles = append(l.fixturesFiles, fixtures...)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@ -534,6 +547,34 @@ func (l *Loader) fixturesFromFiles(fileNames ...string) ([]*fixtureFile, error)
|
||||
return fixtureFiles, nil
|
||||
}
|
||||
|
||||
func (l *Loader) fixturesFromPaths(paths ...string) ([]*fixtureFile, error) {
|
||||
fixtureExtractor := func(p string, isDir bool) ([]*fixtureFile, error) {
|
||||
if isDir {
|
||||
return l.fixturesFromDir(p)
|
||||
}
|
||||
|
||||
return l.fixturesFromFiles(p)
|
||||
}
|
||||
|
||||
var fixtureFiles []*fixtureFile
|
||||
|
||||
for _, p := range paths {
|
||||
f, err := os.Stat(p)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf(`testfixtures: could not stat path "%s": %w`, p, err)
|
||||
}
|
||||
|
||||
fixtures, err := fixtureExtractor(p, f.IsDir())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
fixtureFiles = append(fixtureFiles, fixtures...)
|
||||
}
|
||||
|
||||
return fixtureFiles, nil
|
||||
}
|
||||
|
||||
func (l *Loader) processFileTemplate(f *fixtureFile) error {
|
||||
if !l.template {
|
||||
return nil
|
||||
|
Reference in New Issue
Block a user