runtime: Correct permissions error in unit tests

The tests for watching files would fail if the parent directory of
the tests tmp files was unable to have a watch initialized on it.

To keep everything inside the temp filesystem tree this pushes the
test files down one directory and buffers with a "test" parent dir.

Signed-off-by: Patrick East <east.patrick@gmail.com>
This commit is contained in:
Patrick East
2020-10-19 12:39:13 -07:00
parent ac06c3b73c
commit 343465b9dc
+12 -2
View File
@@ -67,12 +67,17 @@ func testRuntimeProcessWatchEvents(t *testing.T, asBundle bool) {
ctx := context.Background()
fs := map[string]string{
"/some/data.json": `{
"test/some/data.json": `{
"hello": "world"
}`,
}
test.WithTempFS(fs, func(rootDir string) {
// Prefix the directory intended to be watched with at least one
// directory to avoid permission issues on the local host. Otherwise we
// cannot always watch the tmp directory's parent.
rootDir = filepath.Join(rootDir, "test")
params := NewParams()
params.Paths = []string{rootDir}
params.BundleMode = asBundle
@@ -147,13 +152,18 @@ func testRuntimeProcessWatchEventPolicyError(t *testing.T, asBundle bool) {
ctx := context.Background()
fs := map[string]string{
"/x.rego": `package test
"test/x.rego": `package test
default x = 1
`,
}
test.WithTempFS(fs, func(rootDir string) {
// Prefix the directory intended to be watched with at least one
// directory to avoid permission issues on the local host. Otherwise we
// cannot always watch the tmp directory's parent.
rootDir = filepath.Join(rootDir, "test")
params := NewParams()
params.Paths = []string{rootDir}
params.BundleMode = asBundle