MCPcopy
hub / github.com/grpc/grpc-go / createTmpPolicyFile

Function createTmpPolicyFile

authz/grpc_authz_server_interceptors_test.go:31–48  ·  view source on GitHub ↗
(t *testing.T, dirSuffix string, policy []byte)

Source from the content-addressed store, hash-verified

29)
30
31func 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
50func (s) TestNewStatic(t *testing.T) {
51 tests := map[string]struct {

Calls 3

JoinMethod · 0.80
FatalfMethod · 0.65
LogfMethod · 0.65

Tested by

no test coverage detected