mirror of
https://github.com/open-policy-agent/opa.git
synced 2026-08-13 03:42:35 -06:00
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:
+12
-2
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user