testfixtures
testfixtures copied to clipboard
Error when using templates with incorrect order
I like test fixtures but encountered a minor (documentation) problem:
When I use this:
...
testfixtures.Database(db.DB()),
testfixtures.Dialect("sqlite"),
testfixtures.Directory("testdata/fixtures"),
testfixtures.Template(),
testfixtures.TemplateFuncs(template.FuncMap{
"now": now,
}),
I get an error:
testfixtures: could not unmarshal YAML: yaml: invalid map key: map[interface {}]interface {}{"now":interface {}(nil)}
When I move the line with Directory()
down a bit, everything works fine:
testfixtures.Database(db.DB()),
testfixtures.Dialect("sqlite"),
testfixtures.Template(),
testfixtures.TemplateFuncs(template.FuncMap{
"now": now,
}),
testfixtures.Directory("testdata/fixtures"),
I could not see this in the documentation. It might be worth mentioning?
Hi @pgundlach,
Yes, Directory
, Files
and Paths
should always be the last option in the call.