| 13 | ) |
| 14 | |
| 15 | func TestUpgradePromptTermination(t *testing.T) { |
| 16 | ctx, cancel := context.WithCancel(context.Background()) |
| 17 | t.Cleanup(cancel) |
| 18 | |
| 19 | cli := test.NewFakeCli(&fakeClient{ |
| 20 | pluginUpgradeFunc: func(name string, options client.PluginUpgradeOptions) (client.PluginUpgradeResult, error) { |
| 21 | return nil, errors.New("should not be called") |
| 22 | }, |
| 23 | pluginInspectFunc: func(name string) (client.PluginInspectResult, error) { |
| 24 | return client.PluginInspectResult{ |
| 25 | Plugin: plugin.Plugin{ |
| 26 | ID: "5724e2c8652da337ab2eedd19fc6fc0ec908e4bd907c7421bf6a8dfc70c4c078", |
| 27 | Name: "foo/bar", |
| 28 | Enabled: false, |
| 29 | PluginReference: "localhost:5000/foo/bar:v0.1.0", |
| 30 | }, |
| 31 | }, nil |
| 32 | }, |
| 33 | }) |
| 34 | cmd := newUpgradeCommand(cli) |
| 35 | // need to set a remote address that does not match the plugin |
| 36 | // reference sent by the `pluginInspectFunc` |
| 37 | cmd.SetArgs([]string{"foo/bar", "localhost:5000/foo/bar:v1.0.0"}) |
| 38 | cmd.SetOut(io.Discard) |
| 39 | cmd.SetErr(io.Discard) |
| 40 | test.TerminatePrompt(ctx, t, cmd, cli) |
| 41 | golden.Assert(t, cli.OutBuffer().String(), "plugin-upgrade-terminate.golden") |
| 42 | } |