(t *testing.T)
| 46 | } |
| 47 | |
| 48 | func TestExportImportPipe(t *testing.T) { |
| 49 | cli := makeFakeCli(t) |
| 50 | createTestContext(t, cli, "test", map[string]any{ |
| 51 | "MyCustomMetadata": t.Name(), |
| 52 | }) |
| 53 | cli.ErrBuffer().Reset() |
| 54 | cli.OutBuffer().Reset() |
| 55 | assert.NilError(t, runExport(cli, "test", "-")) |
| 56 | assert.Equal(t, cli.ErrBuffer().String(), "") |
| 57 | cli.SetIn(streams.NewIn(io.NopCloser(bytes.NewBuffer(cli.OutBuffer().Bytes())))) |
| 58 | cli.OutBuffer().Reset() |
| 59 | cli.ErrBuffer().Reset() |
| 60 | assert.NilError(t, runImport(cli, "test2", "-")) |
| 61 | context1, err := cli.ContextStore().GetMetadata("test") |
| 62 | assert.NilError(t, err) |
| 63 | context2, err := cli.ContextStore().GetMetadata("test2") |
| 64 | assert.NilError(t, err) |
| 65 | |
| 66 | assert.Check(t, is.DeepEqual(context1.Metadata, command.DockerContext{ |
| 67 | Description: "description of test", |
| 68 | AdditionalFields: map[string]any{"MyCustomMetadata": t.Name()}, |
| 69 | })) |
| 70 | |
| 71 | assert.Check(t, is.DeepEqual(context1.Endpoints, context2.Endpoints)) |
| 72 | assert.Check(t, is.DeepEqual(context1.Metadata, context2.Metadata)) |
| 73 | assert.Check(t, is.Equal("test", context1.Name)) |
| 74 | assert.Check(t, is.Equal("test2", context2.Name)) |
| 75 | |
| 76 | assert.Check(t, is.Equal("test2\n", cli.OutBuffer().String())) |
| 77 | assert.Check(t, is.Equal("Successfully imported context \"test2\"\n", cli.ErrBuffer().String())) |
| 78 | } |
| 79 | |
| 80 | func TestExportExistingFile(t *testing.T) { |
| 81 | contextFile := filepath.Join(t.TempDir(), "exported") |
nothing calls this directly
no test coverage detected
searching dependent graphs…