Skip to content

Commit

Permalink
Show common environment when no environment provided
Browse files Browse the repository at this point in the history
  • Loading branch information
janelletavares committed Dec 20, 2021
1 parent 8e7d75a commit 49c96c4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
10 changes: 10 additions & 0 deletions utils/display.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ func ResourceTable(res *meroxa.Resource) string {
{Text: e},
})
}
} else {
mainTable.Body.Cells = append(mainTable.Body.Cells, []*simpletable.Cell{
{Align: simpletable.AlignRight, Text: "Environment Name:"},
{Text: string(meroxa.EnvironmentTypeCommon)},
})
}

mainTable.SetStyle(simpletable.StyleCompact)
Expand Down Expand Up @@ -152,6 +157,11 @@ func PipelineTable(p *meroxa.Pipeline) string {
{Text: pN},
})
}
} else {
mainTable.Body.Cells = append(mainTable.Body.Cells, []*simpletable.Cell{
{Align: simpletable.AlignRight, Text: "Environment Name:"},
{Text: string(meroxa.EnvironmentTypeCommon)},
})
}

mainTable.Body.Cells = append(mainTable.Body.Cells, []*simpletable.Cell{
Expand Down
13 changes: 5 additions & 8 deletions utils/display_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ func TestPipelineTable(t *testing.T) {
}

tableHeaders := []string{"UUID", "ID", "Name", "State"}
var envHeader = "Environment"
var envHeader = "Environment Name"

for name, p := range tests {
t.Run(name, func(t *testing.T) {
Expand All @@ -504,15 +504,12 @@ func TestPipelineTable(t *testing.T) {
if !strings.Contains(out, pipelineBase.UUID) {
t.Errorf("%s, not found", pipelineBase.UUID)
}
if strings.Contains(out, envHeader) {
t.Errorf("%q header is not necessary", envHeader)
}
case "With_Environment":
if !strings.Contains(out, envHeader) {
t.Errorf("%q header is missing", envHeader)
t.Errorf("%q not found", envHeader)
}
if !strings.Contains(out, pipelineWithEnv.Environment.Name) {
t.Errorf("expected environment name to be %q", pipelineWithEnv.Environment.Name)
case "With_Environment":
if !strings.Contains(out, pipelineWithEnv.Environment.UUID) {
t.Errorf("expected environment UUID to be %q", pipelineWithEnv.Environment.UUID)
}
}
fmt.Println(out)
Expand Down

0 comments on commit 49c96c4

Please sign in to comment.