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

Function createTmpDirWithFiles

credentials/tls/certprovider/pemfile/watcher_test.go:192–208  ·  view source on GitHub ↗

createTempDirWithFiles creates a temporary directory under the system default tempDir with the given dirSuffix. It also reads from certSrc, keySrc and rootSrc files are creates appropriate files under the newly create tempDir. Returns the name of the created tempDir.

(t *testing.T, dirSuffix, certSrc, keySrc, rootSrc, spiffeBundleSrc string)

Source from the content-addressed store, hash-verified

190// rootSrc files are creates appropriate files under the newly create tempDir.
191// Returns the name of the created tempDir.
192func createTmpDirWithFiles(t *testing.T, dirSuffix, certSrc, keySrc, rootSrc, spiffeBundleSrc string) string {
193 t.Helper()
194
195 // Create a temp directory. Passing an empty string for the first argument
196 // uses the system temp directory.
197 dir, err := os.MkdirTemp("", dirSuffix)
198 if err != nil {
199 t.Fatalf("os.MkdirTemp() failed: %v", err)
200 }
201 t.Logf("Using tmpdir: %s", dir)
202
203 createTmpFile(t, testdata.Path(certSrc), path.Join(dir, certFile))
204 createTmpFile(t, testdata.Path(keySrc), path.Join(dir, keyFile))
205 createTmpFile(t, testdata.Path(rootSrc), path.Join(dir, rootFile))
206 createTmpFile(t, testdata.Path(spiffeBundleSrc), path.Join(dir, spiffeBundleFile))
207 return dir
208}
209
210// initializeProvider performs setup steps common to all tests (except the one
211// which uses symlinks).

Callers 2

initializeProviderFunction · 0.85

Calls 5

PathFunction · 0.92
JoinMethod · 0.80
createTmpFileFunction · 0.70
FatalfMethod · 0.65
LogfMethod · 0.65

Tested by

no test coverage detected