MCPcopy Create free account
hub / github.com/containers/common / testNewRuntime

Function testNewRuntime

libimage/runtime_test.go:28–59  ·  view source on GitHub ↗

Create a new Runtime that can be used for testing. The second return value is a clean-up function that should be called by users to make sure all temporary test data gets removed.

(t *testing.T, options ...testNewRuntimeOptions)

Source from the content-addressed store, hash-verified

26// is a clean-up function that should be called by users to make sure all
27// temporary test data gets removed.
28func testNewRuntime(t *testing.T, options ...testNewRuntimeOptions) (runtime *Runtime, cleanup func()) {
29 workdir, err := ioutil.TempDir("", "testStorageRuntime")
30 require.NoError(t, err)
31 storeOptions := &storage.StoreOptions{
32 RunRoot: workdir,
33 GraphRoot: workdir,
34 GraphDriverName: "vfs",
35 }
36
37 // Make sure that the tests do not use the host's registries.conf.
38 systemContext := &types.SystemContext{
39 SystemRegistriesConfPath: "testdata/registries.conf",
40 SystemRegistriesConfDirPath: "/dev/null",
41 }
42
43 if len(options) == 1 && options[0].registriesConfPath != "" {
44 systemContext.SystemRegistriesConfPath = options[0].registriesConfPath
45 }
46
47 runtime, err = RuntimeFromStoreOptions(&RuntimeOptions{SystemContext: systemContext}, storeOptions)
48 require.NoError(t, err)
49 require.Equal(t, runtime.systemContext.BigFilesTemporaryDir, tmpdir())
50
51 cleanup = func() {
52 runtime.Shutdown(true)
53 _ = os.RemoveAll(workdir)
54 }
55
56 sys := runtime.SystemContext()
57 require.NotNil(t, sys)
58 return runtime, cleanup
59}

Callers 15

TestImportFunction · 0.85
TestLoadFunction · 0.85
TestPushFunction · 0.85
TestPushOtherPlatformFunction · 0.85
TestImageFunctionsFunction · 0.85
TestInspectHealthcheckFunction · 0.85
TestTagFunction · 0.85
TestUntagFunction · 0.85
TestCorruptedLayersFunction · 0.85
TestCreateManifestListFunction · 0.85

Calls 4

RuntimeFromStoreOptionsFunction · 0.85
tmpdirFunction · 0.85
ShutdownMethod · 0.80
SystemContextMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…