Skip to content

Commit

Permalink
fix dashboardURL tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wpjunior committed Aug 12, 2024
1 parent ac8c61a commit 0d505a7
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tsuru/client/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ const simplifiedFormat = `{{ if .Error -}}
Error: {{ .Error }}
{{ end -}}
Application: {{.Name}}
{{ if .DashboardURL -}}
{{- if .DashboardURL }}
Dashboard: {{ .DashboardURL }}
{{- end }}
{{- if .Description }}
Expand Down Expand Up @@ -690,7 +690,7 @@ const fullFormat = `{{ if .Error -}}
Error: {{ .Error }}
{{ end -}}
Application: {{.Name}}
{{ if .DashboardURL -}}
{{- if .DashboardURL }}
Dashboard: {{ .DashboardURL }}
{{- end }}
{{- if .Description }}
Expand Down
36 changes: 36 additions & 0 deletions tsuru/client/apps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1921,6 +1921,42 @@ Units: 3
c.Assert(stdout.String(), check.Equals, expected)
}

func (s *S) TestAppInfoDashboardURL(c *check.C) {
var stdout, stderr bytes.Buffer
result := `{"name":"app1","teamowner":"myteam","ip":"myapp.tsuru.io","cname":["yourapp.tsuru.io"],"platform":"php","repository":"[email protected]:php.git","state":"dead","units":[{"ID":"app1/0","Status":"started"}, {"ID":"app1/1","Status":"started"}, {"Ip":"","ID":"app1/2","Status":"pending"}],"Teams":["tsuruteam","crane"], "owner": "myapp_owner", "deploys": 7, "router": "planb", "dashboardURL": "http://dashboard.tsuru.io/app1"}`
expected := `Application: app1
Dashboard: http://dashboard.tsuru.io/app1
Platform: php
Router: planb
Teams: myteam (owner), tsuruteam, crane
External Addresses: yourapp.tsuru.io (cname), myapp.tsuru.io
Created by: myapp_owner
Deploys: 7
Pool:
Quota: 0/0 units
Units: 3
+--------+---------+------+------+
| Name | Status | Host | Port |
+--------+---------+------+------+
| app1/0 | started | | |
| app1/1 | started | | |
| app1/2 | pending | | |
+--------+---------+------+------+
`
context := cmd.Context{
Stdout: &stdout,
Stderr: &stderr,
}
s.setupFakeTransport(&cmdtest.Transport{Message: result, Status: http.StatusOK})
command := AppInfo{}
command.Flags().Parse(true, []string{"--app", "app1"})
err := command.Run(&context)
c.Assert(err, check.IsNil)
c.Assert(stdout.String(), check.Equals, expected)
}

func (s *S) TestAppInfoWithServices(c *check.C) {
var stdout, stderr bytes.Buffer
expected := `Application: app1
Expand Down

0 comments on commit 0d505a7

Please sign in to comment.