Skip to content

Commit

Permalink
CLI: Expand test to include testing the json flag for allocation checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Juanadelacuesta committed Mar 10, 2023
1 parent c48be56 commit ec213a8
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions command/alloc_checks_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package command

import (
"encoding/json"
"testing"

"github.com/hashicorp/nomad/api"
"github.com/hashicorp/nomad/ci"
"github.com/hashicorp/nomad/nomad/mock"
"github.com/hashicorp/nomad/nomad/structs"
Expand Down Expand Up @@ -83,6 +85,7 @@ func TestAllocChecksCommand_AutocompleteArgs(t *testing.T) {
func TestAllocChecksCommand_Run(t *testing.T) {
ci.Parallel(t)
srv, client, url := testServer(t, true, nil)

defer srv.Shutdown()

// wait for nodes
Expand Down Expand Up @@ -117,4 +120,15 @@ func TestAllocChecksCommand_Run(t *testing.T) {
must.StrContains(t, out, `Task = (group)`)
must.StrContains(t, out, `Service = service1`)
must.StrContains(t, out, `Mode = healthiness`)

ui.OutputWriter.Reset()
// List json
cmd = &AllocChecksCommand{Meta: Meta{Ui: ui, flagAddress: url}}
must.Zero(t, cmd.Run([]string{"-address=" + url, "-json", allocID}))

outJson := api.AllocCheckStatuses{}
err = json.Unmarshal(ui.OutputWriter.Bytes(), &outJson)
must.NoError(t, err)

ui.OutputWriter.Reset()
}

0 comments on commit ec213a8

Please sign in to comment.