Skip to content

Commit

Permalink
Merge branch 'env-table-display' of https://github.com/meroxa/cli
Browse files Browse the repository at this point in the history
  • Loading branch information
anna-cross committed Jan 18, 2022
2 parents ba8117e + bb85d29 commit 2c574d6
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 16 deletions.
35 changes: 27 additions & 8 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 Expand Up @@ -304,16 +314,25 @@ func ConnectorTable(connector *meroxa.Connector) string {
{Text: connector.Trace},
})
}
var env string
if connector.Environment != nil && connector.Environment.Name != "" {
env = connector.Environment.Name
if connector.Environment != nil {
if envUUID := connector.Environment.UUID; envUUID != "" {
mainTable.Body.Cells = append(mainTable.Body.Cells, []*simpletable.Cell{
{Align: simpletable.AlignRight, Text: "Environment UUID:"},
{Text: envUUID},
})
}
if envName := connector.Environment.Name; envName != "" {
mainTable.Body.Cells = append(mainTable.Body.Cells, []*simpletable.Cell{
{Align: simpletable.AlignRight, Text: "Environment Name:"},
{Text: envName},
})
}
} else {
env = string(meroxa.EnvironmentTypeCommon)
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{
{Align: simpletable.AlignRight, Text: "Environment:"},
{Text: env},
})

mainTable.SetStyle(simpletable.StyleCompact)

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 2c574d6

Please sign in to comment.