testfixtures icon indicating copy to clipboard operation
testfixtures copied to clipboard

Error when using templates with incorrect order

Open pgundlach opened this issue 4 years ago • 1 comments

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?

pgundlach avatar Jan 25 '21 17:01 pgundlach

Hi @pgundlach,

Yes, Directory, Files and Paths should always be the last option in the call.

andreynering avatar Jun 05 '21 19:06 andreynering