File path to resources wrong in tests

I just have a question related to file paths for resources in tests. I have a http service that has a path to json files that it uses in a restful micro service and it works.

If i write tests test the handlers the tests do not find the files. I am fairly new to go, am I missing something obvious?

if i make up the content without using the files, the tests pass

but using listen and serve, it finds the assets ok. if i re name them the service does not find the file as expected.

Let’s see some example code

In the meantime, review Dave Cheney’s blog on this - always a good resource.

sorry i figured it out; just have not had a chance to update.

instead of passing a relative path:
“report-api/data/assets/file.JSON”

// this works for the service and my tests
wd, _ := os.Getwd()
for !strings.HasSuffix(wd, “report-api”) {
wd = filepath.Dir(wd)
}

great site