Skip to content

Commit

Permalink
feat: update wording on remove
Browse files Browse the repository at this point in the history
  • Loading branch information
raulb committed Oct 18, 2021
1 parent 35a1643 commit 9ebdc61
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
1 change: 1 addition & 0 deletions cmd/meroxa/root/environments/describe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"
"encoding/json"
"errors"

"github.com/golang/mock/gomock"
"github.com/meroxa/cli/log"
mock "github.com/meroxa/cli/mock-cmd"
Expand Down
5 changes: 3 additions & 2 deletions cmd/meroxa/root/environments/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package environments
import (
"context"
"errors"

"github.com/meroxa/cli/cmd/meroxa/builder"
"github.com/meroxa/cli/log"
"github.com/meroxa/meroxa-go"
Expand Down Expand Up @@ -64,15 +65,15 @@ func (r *Remove) Confirm(_ context.Context) (wantInput string) {
}

func (r *Remove) Execute(ctx context.Context) error {
r.logger.Infof(ctx, "Removing environment %q...", r.args.Name)
r.logger.Infof(ctx, "Environment %q is being removed...", r.args.Name)

// TODO: Check if this could return also env
err := r.client.DeleteEnvironment(ctx, r.args.Name)
if err != nil {
return err
}

r.logger.Infof(ctx, "Environment %q successfully removed", r.args.Name)
r.logger.Infof(ctx, "Run `meroxa env describe %s` for status.", r.args.Name)

e, err := r.client.GetEnvironment(ctx, r.args.Name)
if err != nil {
Expand Down
14 changes: 8 additions & 6 deletions cmd/meroxa/root/environments/remove_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@ import (
"context"
"encoding/json"
"errors"
"strings"

"fmt"
"reflect"
"testing"

"github.com/golang/mock/gomock"
"github.com/meroxa/cli/log"
mock "github.com/meroxa/cli/mock-cmd"
"github.com/meroxa/cli/utils"
"github.com/meroxa/meroxa-go"
"reflect"
"testing"
)

func TestRemoveEnvironmentArgs(t *testing.T) {
Expand Down Expand Up @@ -87,11 +90,10 @@ func TestRemoveEnvironmentExecution(t *testing.T) {
}

gotLeveledOutput := logger.LeveledOutput()
wantLeveledOutput := fmt.Sprintf(`Removing environment %q...
Environment %q successfully removed
`, e.Name, e.Name)
wantLeveledOutput := fmt.Sprintf("Environment %q is being removed...\n", e.Name)
wantLeveledOutput += fmt.Sprintf("Run `meroxa env describe %s` for status.", e.Name)

if gotLeveledOutput != wantLeveledOutput {
if !strings.Contains(gotLeveledOutput, wantLeveledOutput) {
t.Fatalf("expected output:\n%s\ngot:\n%s", wantLeveledOutput, gotLeveledOutput)
}

Expand Down
4 changes: 2 additions & 2 deletions utils/display.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ func EnvironmentsTable(environments []*meroxa.Environment, hideHeaders bool) str
func EnvironmentTable(environment *meroxa.Environment) string {
mainTable := simpletable.New()

envStatus := fmt.Sprintf("%s", environment.Status.State)
envStatus := environment.Status.State

if environment.Status.Details != "" {
envStatus += fmt.Sprintf("\n\nDetails: %s", environment.Status.Details)
Expand All @@ -408,7 +408,7 @@ func EnvironmentTable(environment *meroxa.Environment) string {
mainTable.Body.Cells = [][]*simpletable.Cell{
{
{Align: simpletable.AlignRight, Text: "UUID:"},
{Text: fmt.Sprintf("%s", environment.UUID)},
{Text: environment.UUID},
},
{
{Align: simpletable.AlignRight, Text: "Name:"},
Expand Down

0 comments on commit 9ebdc61

Please sign in to comment.