-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b8245f5
commit 10c6d65
Showing
3 changed files
with
57 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,6 @@ indent_size = 2 | |
|
||
[*.yml] | ||
indent_size = 2 | ||
|
||
[*.go] | ||
indent_style = tab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: golangci-lint | ||
|
||
on: | ||
push: | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
golangci: | ||
name: lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: stable | ||
|
||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v6 | ||
with: | ||
version: v1.60 | ||
working-directory: go-tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,36 @@ | ||
package tests | ||
|
||
import ( | ||
"net/http/httptest" | ||
"net/url" | ||
"strings" | ||
"testing" | ||
"net/http/httptest" | ||
"net/url" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/platformsh/cli/pkg/mockapi" | ||
"github.com/platformsh/cli/pkg/mockapi" | ||
) | ||
|
||
func TestOrgList(t *testing.T) { | ||
authServer := mockapi.NewAuthServer(t) | ||
defer authServer.Close() | ||
authServer := mockapi.NewAuthServer(t) | ||
defer authServer.Close() | ||
|
||
myUserID := "user-id-1" | ||
myUserID := "user-id-1" | ||
|
||
apiHandler := mockapi.NewHandler(t) | ||
apiHandler.SetMyUser(&mockapi.User{ID: myUserID}) | ||
apiHandler.SetOrgs([]*mockapi.Org{ | ||
makeOrg("org-id-1", "acme", "ACME Inc.", myUserID), | ||
makeOrg("org-id-2", "four-seasons", "Four Seasons Total Landscaping", myUserID), | ||
makeOrg("org-id-3", "duff", "Duff Beer", "user-id-2"), | ||
}) | ||
apiHandler := mockapi.NewHandler(t) | ||
apiHandler.SetMyUser(&mockapi.User{ID: myUserID}) | ||
apiHandler.SetOrgs([]*mockapi.Org{ | ||
makeOrg("org-id-1", "acme", "ACME Inc.", myUserID), | ||
makeOrg("org-id-2", "four-seasons", "Four Seasons Total Landscaping", myUserID), | ||
makeOrg("org-id-3", "duff", "Duff Beer", "user-id-2"), | ||
}) | ||
|
||
apiServer := httptest.NewServer(apiHandler) | ||
defer apiServer.Close() | ||
apiServer := httptest.NewServer(apiHandler) | ||
defer apiServer.Close() | ||
|
||
run := runnerWithAuth(t, apiServer.URL, authServer.URL) | ||
run := runnerWithAuth(t, apiServer.URL, authServer.URL) | ||
|
||
assert.Equal(t, strings.TrimLeft(` | ||
assert.Equal(t, strings.TrimLeft(` | ||
+--------------+--------------------------------+-----------------------+ | ||
| Name | Label | Owner email | | ||
+--------------+--------------------------------+-----------------------+ | ||
|
@@ -40,27 +40,27 @@ func TestOrgList(t *testing.T) { | |
+--------------+--------------------------------+-----------------------+ | ||
`, "\n"), run("orgs")) | ||
|
||
assert.Equal(t, strings.TrimLeft(` | ||
assert.Equal(t, strings.TrimLeft(` | ||
Name Label Owner email | ||
acme ACME Inc. [email protected] | ||
duff Duff Beer [email protected] | ||
four-seasons Four Seasons Total Landscaping [email protected] | ||
`, "\n"), run("orgs", "--format", "plain")) | ||
|
||
assert.Equal(t, strings.TrimLeft(` | ||
assert.Equal(t, strings.TrimLeft(` | ||
org-id-1,acme | ||
org-id-3,duff | ||
org-id-2,four-seasons | ||
`, "\n"), run("orgs", "--format", "csv", "--columns", "id,name", "--no-header")) | ||
} | ||
|
||
func makeOrg(id, name, label, owner string) *mockapi.Org { | ||
return &mockapi.Org{ | ||
ID: id, | ||
Name: name, | ||
Label: label, | ||
Owner: owner, | ||
Capabilities: []string{}, | ||
Links: mockapi.MakeHALLinks("self=/organizations/" + url.PathEscape(id)), | ||
} | ||
return &mockapi.Org{ | ||
ID: id, | ||
Name: name, | ||
Label: label, | ||
Owner: owner, | ||
Capabilities: []string{}, | ||
Links: mockapi.MakeHALLinks("self=/organizations/" + url.PathEscape(id)), | ||
} | ||
} |