From 55cd74efca2183609b338b4a34847cc2d01e64c0 Mon Sep 17 00:00:00 2001 From: renovate Date: Mon, 11 May 2020 10:10:15 +0000 Subject: [PATCH] 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 --- go.mod | 2 +- go.sum | 2 + .../testfixtures/v3/CHANGELOG.md | 7 ++- .../go-testfixtures/testfixtures/v3/README.md | 19 ++++++++ .../testfixtures/v3/testfixtures.go | 45 ++++++++++++++++++- vendor/modules.txt | 2 +- 6 files changed, 72 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index e24edc6f5a..86e219cd6c 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index e66373b432..a9b220e181 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/vendor/github.com/go-testfixtures/testfixtures/v3/CHANGELOG.md b/vendor/github.com/go-testfixtures/testfixtures/v3/CHANGELOG.md index d08391926e..2b8aa4b70a 100644 --- a/vendor/github.com/go-testfixtures/testfixtures/v3/CHANGELOG.md +++ b/vendor/github.com/go-testfixtures/testfixtures/v3/CHANGELOG.md @@ -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 diff --git a/vendor/github.com/go-testfixtures/testfixtures/v3/README.md b/vendor/github.com/go-testfixtures/testfixtures/v3/README.md index 8c30e47817..56ca8aa455 100644 --- a/vendor/github.com/go-testfixtures/testfixtures/v3/README.md +++ b/vendor/github.com/go-testfixtures/testfixtures/v3/README.md @@ -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 diff --git a/vendor/github.com/go-testfixtures/testfixtures/v3/testfixtures.go b/vendor/github.com/go-testfixtures/testfixtures/v3/testfixtures.go index 3b7ef8c79d..7125b38c1d 100644 --- a/vendor/github.com/go-testfixtures/testfixtures/v3/testfixtures.go +++ b/vendor/github.com/go-testfixtures/testfixtures/v3/testfixtures.go @@ -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 diff --git a/vendor/modules.txt b/vendor/modules.txt index d1cdffcbb5..5ebcd30aef 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -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