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