INNER CODE UNIT · Go

newRuntimeTestContext

alexei-led/pumba · cmd/main_test.go:51

func newRuntimeTestContext(t *testing.T, values map[string]string) *cli.Context {
	t.Helper()
	app := cli.NewApp()
	fs := flag.NewFlagSet("test", flag.ContinueOnError)
	for _, f := range globalFlags("/tmp/certs") {
		f.Apply(fs)
	}
	for k, v := range values {
		require.NoError(t, fs.Set(k, v))
	}
	return cli.NewContext(app, fs, nil)
}

// restoreFactories snapshots the runtime-client factory vars and returns a
// cleanup func so tests can swap them without leaking state across subtests.
func restoreFactories(t *testing.T) {
	t.Helper()
	origDocker := newDockerClient

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…