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)
| 26 | // is a clean-up function that should be called by users to make sure all |
| 27 | // temporary test data gets removed. |
| 28 | func 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 | } |
no test coverage detected
searching dependent graphs…