Skip to content

Commit

Permalink
plan: Add tests for --cpu-burst-factor
Browse files Browse the repository at this point in the history
  • Loading branch information
wpjunior committed Oct 11, 2023
1 parent fcc4de3 commit 6110952
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tsuru/client/apps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down

0 comments on commit 6110952

Please sign in to comment.