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:
renovate 2020-05-11 10:10:15 +00:00 committed by konrad
parent a9d0079bf3
commit 55cd74efca
6 changed files with 72 additions and 5 deletions

2
go.mod
View file

@ -35,7 +35,7 @@ require (
github.com/go-openapi/spec v0.19.4 // indirect
github.com/go-redis/redis/v7 v7.2.0
github.com/go-sql-driver/mysql v1.5.0
github.com/go-testfixtures/testfixtures/v3 v3.1.2
github.com/go-testfixtures/testfixtures/v3 v3.2.0
github.com/gordonklaus/ineffassign v0.0.0-20200309095847-7953dde2c7bf
github.com/iancoleman/strcase v0.0.0-20191112232945-16388991a334
github.com/imdario/mergo v0.3.9

2
go.sum
View file

@ -162,6 +162,8 @@ github.com/go-testfixtures/testfixtures/v3 v3.1.1 h1:SBIfzULODQQ7JV6AD931MvAz8pn
github.com/go-testfixtures/testfixtures/v3 v3.1.1/go.mod h1:RZctY24ixituGC73XlAV1gkCwYMVwiSwPm26MNlQIhE=
github.com/go-testfixtures/testfixtures/v3 v3.1.2 h1:sACIJoknTtWHbz5wahA6f50IGsz7oBXS+jgm0eKl4eI=
github.com/go-testfixtures/testfixtures/v3 v3.1.2/go.mod h1:RZctY24ixituGC73XlAV1gkCwYMVwiSwPm26MNlQIhE=
github.com/go-testfixtures/testfixtures/v3 v3.2.0 h1:FGAW3z5UzmrZGjR/dZp1u3Tbld0SDmirLO4RrR5++7Q=
github.com/go-testfixtures/testfixtures/v3 v3.2.0/go.mod h1:RZctY24ixituGC73XlAV1gkCwYMVwiSwPm26MNlQIhE=
github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=

View file

@ -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

View file

@ -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

View file

@ -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

2
vendor/modules.txt vendored
View file

@ -76,7 +76,7 @@ github.com/go-redis/redis/v7/internal/proto
github.com/go-redis/redis/v7/internal/util
# github.com/go-sql-driver/mysql v1.5.0
github.com/go-sql-driver/mysql
# github.com/go-testfixtures/testfixtures/v3 v3.1.2
# github.com/go-testfixtures/testfixtures/v3 v3.2.0
github.com/go-testfixtures/testfixtures/v3
# github.com/golang/protobuf v1.4.0
github.com/golang/protobuf/proto