markbates / pkger

Embed static files in Go binaries (replacement for gobuffalo/packr)
MIT License
1.19k stars 60 forks source link

Force reading packaged data in development/test mode? #127

Open dmoles opened 4 years ago

dmoles commented 4 years ago

I'm trying to write a test to verify that pkged.go matches the contents of my resource directory, which I can then incorporate into a CI pipeline to make sure the generated code committed to the repo is up to date.

Unfortunately, my first naive attempt (using filepath.Walk() to walk the resource directory, and comparing the contents with the results from pkger.Open) made it clear that pkger.Open is just reading the source directory, not the packaged data in pkged.go. (E.g., the test still passes if I add a new file to the resource directory after packaging.) In fact, as far as I can tell, in test, the code in pkged.go (pkger.Apply() etc.) isn't even being executed.

How can I convince pkger to read the packaged data? Or am I fundamentally misunderstanding something here?

dmoles commented 4 years ago

See test here, and associated repo (tag pkger-127).