(t *testing.T, dirSuffix string, policy []byte)
| 29 | ) |
| 30 | |
| 31 | func createTmpPolicyFile(t *testing.T, dirSuffix string, policy []byte) string { |
| 32 | t.Helper() |
| 33 | |
| 34 | // Create a temp directory. Passing an empty string for the first argument |
| 35 | // uses the system temp directory. |
| 36 | dir, err := os.MkdirTemp("", dirSuffix) |
| 37 | if err != nil { |
| 38 | t.Fatalf("os.MkdirTemp() failed: %v", err) |
| 39 | } |
| 40 | t.Logf("Using tmpdir: %s", dir) |
| 41 | // Write policy into file. |
| 42 | filename := path.Join(dir, "policy.json") |
| 43 | if err := os.WriteFile(filename, policy, os.ModePerm); err != nil { |
| 44 | t.Fatalf("os.WriteFile(%q) failed: %v", filename, err) |
| 45 | } |
| 46 | t.Logf("Wrote policy %s to file at %s", string(policy), filename) |
| 47 | return filename |
| 48 | } |
| 49 | |
| 50 | func (s) TestNewStatic(t *testing.T) { |
| 51 | tests := map[string]struct { |
no test coverage detected