diff --git a/commands/orchestrationcommands/stackcommands/delete.go b/commands/orchestrationcommands/stackcommands/delete.go index 2474931..a628857 100644 --- a/commands/orchestrationcommands/stackcommands/delete.go +++ b/commands/orchestrationcommands/stackcommands/delete.go @@ -77,8 +77,10 @@ func (command *commandDelete) HandlePipe(resource *handler.Resource, item string if err != nil { return err } - resource.Params.(*paramsDelete).stackName = name - resource.Params.(*paramsDelete).stackID = id + resource.Params = ¶msDelete{ + stackName: name, + stackID: id, + } return nil } diff --git a/commands/orchestrationcommands/stackcommands/delete_test.go b/commands/orchestrationcommands/stackcommands/delete_test.go index 61fff44..2d457d1 100644 --- a/commands/orchestrationcommands/stackcommands/delete_test.go +++ b/commands/orchestrationcommands/stackcommands/delete_test.go @@ -68,6 +68,35 @@ func TestDeleteHandleSingle(t *testing.T) { th.AssertEquals(t, expected.Params.(*paramsDelete).stackID, actual.Params.(*paramsDelete).stackID) } +func TestDeleteHandlePipe(t *testing.T) { + app := cli.NewApp() + flagset := flag.NewFlagSet("flags", 1) + flagset.String("name", "", "") + flagset.String("id", "", "") + flagset.Set("name", "stack1") + flagset.Set("id", "id1") + c := cli.NewContext(app, flagset, nil) + cmd := &commandDelete{ + Ctx: &handler.Context{ + CLIContext: c, + }, + } + + expected := &handler.Resource{ + Params: ¶msDelete{ + stackName: "stack1", + stackID: "id1", + }, + } + actual := &handler.Resource{ + Params: ¶msDelete{}, + } + err := cmd.HandlePipe(actual, "stack1") + th.AssertNoErr(t, err) + th.AssertEquals(t, expected.Params.(*paramsDelete).stackName, actual.Params.(*paramsDelete).stackName) + th.AssertEquals(t, expected.Params.(*paramsDelete).stackID, actual.Params.(*paramsDelete).stackID) +} + func TestDeleteExecute(t *testing.T) { th.SetupHTTP() defer th.TeardownHTTP()