From 343465b9dc6a74ea083c12afffaecbbe28e25ebb Mon Sep 17 00:00:00 2001 From: Patrick East Date: Mon, 19 Oct 2020 12:39:13 -0700 Subject: [PATCH] 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 --- runtime/runtime_test.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/runtime/runtime_test.go b/runtime/runtime_test.go index a3050af11d..c7ca1c90a5 100644 --- a/runtime/runtime_test.go +++ b/runtime/runtime_test.go @@ -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