diff --git a/tsuru/client/apps_test.go b/tsuru/client/apps_test.go index 8951b64b..5cd27fd8 100644 --- a/tsuru/client/apps_test.go +++ b/tsuru/client/apps_test.go @@ -613,6 +613,40 @@ func (s *S) TestAppUpdateWithCPUAndMemory(c *check.C) { c.Assert(stdout.String(), check.Equals, expected) } +func (s *S) TestAppUpdateWithCPUBurst(c *check.C) { + var stdout, stderr bytes.Buffer + expected := fmt.Sprintf("App %q has been updated!\n", "ble") + context := cmd.Context{ + Stdout: &stdout, + Stderr: &stderr, + } + trans := &cmdtest.ConditionalTransport{ + Transport: cmdtest.Transport{Status: http.StatusOK}, + CondFunc: func(req *http.Request) bool { + url := strings.HasSuffix(req.URL.Path, "/apps/ble") + method := req.Method == "PUT" + data, err := io.ReadAll(req.Body) + c.Assert(err, check.IsNil) + var result map[string]interface{} + err = json.Unmarshal(data, &result) + c.Assert(err, check.IsNil) + c.Assert(result, check.DeepEquals, map[string]interface{}{ + "planoverride": map[string]interface{}{ + "cpuBurst": float64(1.3), + }, + "metadata": map[string]interface{}{}, + }) + return url && method + }, + } + client := cmd.NewClient(&http.Client{Transport: trans}, nil, manager) + command := AppUpdate{} + command.Flags().Parse(true, []string{"-a", "ble", "--cpu-burst-factor", "1.3"}) + err := command.Run(&context, client) + c.Assert(err, check.IsNil) + c.Assert(stdout.String(), check.Equals, expected) +} + func (s *S) TestAppUpdateWithoutArgs(c *check.C) { var stdout, stderr bytes.Buffer expected := "Please use the -a/--app flag to specify which app you want to update."