-
Notifications
You must be signed in to change notification settings - Fork 10
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
fe736f0
commit 364339d
Showing
4 changed files
with
101 additions
and
0 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
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
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,78 @@ | ||
package tests | ||
|
||
import ( | ||
"net/http/httptest" | ||
"net/url" | ||
"strings" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/platformsh/cli/internal/mockapi" | ||
) | ||
|
||
func TestProjectInfo(t *testing.T) { | ||
authServer := mockapi.NewAuthServer(t) | ||
defer authServer.Close() | ||
|
||
myUserID := "my-user-id" | ||
vendor := "test-vendor" | ||
|
||
apiHandler := mockapi.NewHandler(t) | ||
apiHandler.SetMyUser(&mockapi.User{ID: myUserID}) | ||
apiServer := httptest.NewServer(apiHandler) | ||
defer apiServer.Close() | ||
|
||
apiHandler.SetOrgs([]*mockapi.Org{ | ||
makeOrg("org-id-1", "org-1", "Org 1", myUserID), | ||
}) | ||
created, err := time.Parse(time.RFC3339, "2014-04-01T10:00:00+01:00") | ||
require.NoError(t, err) | ||
apiHandler.SetProjects([]*mockapi.Project{ | ||
{ | ||
ID: mockProjectID, | ||
Title: "Project 1", | ||
Region: "region-1", | ||
Organization: "org-id-1", | ||
Vendor: vendor, | ||
Repository: mockapi.ProjectRepository{ | ||
URL: "[email protected]:mock-project.git", | ||
}, | ||
DefaultBranch: "main", | ||
CreatedAt: created, | ||
UpdatedAt: created.Add(time.Second * 86400), | ||
Links: mockapi.MakeHALLinks( | ||
"self=/projects/"+url.PathEscape(mockProjectID), | ||
"#edit=/projects/"+url.PathEscape(mockProjectID), | ||
), | ||
}, | ||
}) | ||
|
||
run := runnerWithAuth(t, apiServer.URL, authServer.URL) | ||
|
||
assert.Equal(t, strings.TrimLeft(` | ||
Property Value | ||
id abcdefg123456 | ||
title Project 1 | ||
region region-1 | ||
organization org-id-1 | ||
vendor test-vendor | ||
repository url: '[email protected]:mock-project.git' | ||
default_branch main | ||
created_at 2014-04-01T09:00:00+00:00 | ||
updated_at 2014-04-02T09:00:00+00:00 | ||
git [email protected]:mock-project.git | ||
url `+apiServer.URL+`/projects/abcdefg123456 | ||
`, "\n"), run("pro:info", "-p", mockProjectID, "--format", "plain")) | ||
|
||
assert.Equal(t, "2014-04-02\n", run("pro:info", "-p", mockProjectID, "updated_at", "--date-fmt", "Y-m-d")) | ||
|
||
assert.Equal(t, "Project 1\n", run("pro:info", "-p", mockProjectID, "title")) | ||
|
||
run("pro:info", "-v", "-p", mockProjectID, "title", "New Title") | ||
|
||
// TODO --refresh should not be needed here | ||
assert.Equal(t, "New Title\n", run("pro:info", "-p", mockProjectID, "title", "--refresh")) | ||
} |
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