Skip to content

Commit ffc4810

Browse files
committed
Add a test
1 parent 2a3b045 commit ffc4810

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

go-tests/web_console_test.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package tests
2+
3+
import (
4+
"net/http/httptest"
5+
"testing"
6+
7+
"github.com/platformsh/cli/pkg/mockapi"
8+
"github.com/stretchr/testify/assert"
9+
)
10+
11+
func TestWebConsole(t *testing.T) {
12+
authServer := mockapi.NewAuthServer(t)
13+
defer authServer.Close()
14+
15+
apiHandler := mockapi.NewHandler(t)
16+
apiServer := httptest.NewServer(apiHandler)
17+
defer apiServer.Close()
18+
19+
projectID := mockapi.ProjectID()
20+
21+
apiHandler.SetOrgs([]*mockapi.Org{
22+
makeOrg("cli-test-id", "cli-tests", "CLI Test Org", "my-user-id"),
23+
})
24+
25+
apiHandler.SetProjects([]*mockapi.Project{{
26+
ID: projectID,
27+
Links: mockapi.MakeHALLinks("self=/projects/"+projectID,
28+
"environments=/projects/"+projectID+"/environments"),
29+
DefaultBranch: "main",
30+
Organization: "cli-test-id",
31+
}})
32+
main := makeEnv(projectID, "main", "production", "active", nil)
33+
envs := []*mockapi.Environment{main}
34+
apiHandler.SetEnvironments(envs)
35+
36+
f := newCommandFactory(t, apiServer.URL, authServer.URL)
37+
38+
assert.Equal(t, "https://console.cli-tests.example.com\n", f.Run("console", "--browser", "0"))
39+
40+
assert.Equal(t, "https://console.cli-tests.example.com/cli-tests/"+projectID+"\n",
41+
f.Run("console", "--browser", "0", "-p", projectID))
42+
43+
assert.Equal(t, "https://console.cli-tests.example.com/cli-tests/"+projectID+"/main\n",
44+
f.Run("console", "--browser", "0", "-p", projectID, "-e", "."))
45+
46+
// The "console" command should be aliased to "web".
47+
assert.Equal(t, "https://console.cli-tests.example.com\n", f.Run("web", "--browser", "0"))
48+
}

0 commit comments

Comments
 (0)