(t *testing.T)
| 15 | ) |
| 16 | |
| 17 | func TestExportImportWithFile(t *testing.T) { |
| 18 | contextFile := filepath.Join(t.TempDir(), "exported") |
| 19 | cli := makeFakeCli(t) |
| 20 | createTestContext(t, cli, "test", map[string]any{ |
| 21 | "MyCustomMetadata": t.Name(), |
| 22 | }) |
| 23 | cli.ErrBuffer().Reset() |
| 24 | assert.NilError(t, runExport(cli, "test", contextFile)) |
| 25 | assert.Equal(t, cli.ErrBuffer().String(), fmt.Sprintf("Written file %q\n", contextFile)) |
| 26 | cli.OutBuffer().Reset() |
| 27 | cli.ErrBuffer().Reset() |
| 28 | assert.NilError(t, runImport(cli, "test2", contextFile)) |
| 29 | context1, err := cli.ContextStore().GetMetadata("test") |
| 30 | assert.NilError(t, err) |
| 31 | context2, err := cli.ContextStore().GetMetadata("test2") |
| 32 | assert.NilError(t, err) |
| 33 | |
| 34 | assert.Check(t, is.DeepEqual(context1.Metadata, command.DockerContext{ |
| 35 | Description: "description of test", |
| 36 | AdditionalFields: map[string]any{"MyCustomMetadata": t.Name()}, |
| 37 | })) |
| 38 | |
| 39 | assert.Check(t, is.DeepEqual(context1.Endpoints, context2.Endpoints)) |
| 40 | assert.Check(t, is.DeepEqual(context1.Metadata, context2.Metadata)) |
| 41 | assert.Check(t, is.Equal("test", context1.Name)) |
| 42 | assert.Check(t, is.Equal("test2", context2.Name)) |
| 43 | |
| 44 | assert.Check(t, is.Equal("test2\n", cli.OutBuffer().String())) |
| 45 | assert.Check(t, is.Equal("Successfully imported context \"test2\"\n", cli.ErrBuffer().String())) |
| 46 | } |
| 47 | |
| 48 | func TestExportImportPipe(t *testing.T) { |
| 49 | cli := makeFakeCli(t) |
nothing calls this directly
no test coverage detected
searching dependent graphs…