-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
7 changed files
with
76 additions
and
13 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
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
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 |
---|---|---|
|
@@ -42,7 +42,7 @@ func (ts *TestSuite) Test_tenantsCreateHandler() { | |
// TODO: test error response | ||
} | ||
|
||
func (ts *TestSuite) Test_GetTenant() { | ||
func (ts *TestSuite) Test_tenantsGetHandler() { | ||
f := ts.createUserFixture() | ||
token := f.Tokens[0] | ||
tenant := ts.createTenantFixture().Tenants[0] | ||
|
@@ -66,7 +66,7 @@ func (ts *TestSuite) Test_GetTenant() { | |
// TODO: test error response | ||
} | ||
|
||
func (ts *TestSuite) Test_GetTenantList() { | ||
func (ts *TestSuite) Test_tenantsListHandler() { | ||
f := ts.createUserFixture() | ||
token := f.Tokens[0] | ||
tenant := ts.createTenantFixture().Tenants[0] | ||
|
@@ -83,10 +83,37 @@ func (ts *TestSuite) Test_GetTenantList() { | |
// Assertions | ||
ts.Equal(http.StatusOK, res.Code, "incorrect http status, body: \n%s", body) | ||
|
||
var Tenants []app.Tenant | ||
ts.NoError(json.Unmarshal(body, &Tenants)) | ||
ts.Len(Tenants, 1) | ||
ts.Equal(tenant.ID, Tenants[0].ID, "incorrect Tenant ID, body: \n%s", body) | ||
var tenants []app.Tenant | ||
ts.NoError(json.Unmarshal(body, &tenants)) | ||
ts.Len(tenants, 1) | ||
ts.Equal(tenant.ID, tenants[0].ID, "incorrect Tenant ID, body: \n%s", body) | ||
|
||
// TODO: test error response | ||
} | ||
|
||
func (ts *TestSuite) Test_tenantsUsersCreateHandler() { | ||
f := ts.createUserFixture() | ||
token := f.Tokens[0] | ||
tenant := ts.createTenantFixture().Tenants[0] | ||
|
||
input := app.TenantUserCreateInput{Email: "[email protected]"} | ||
j, _ := json.Marshal(&input) | ||
req := httptest.NewRequest(http.MethodPost, "/api/tenants/"+tenant.ID+"/users", bytes.NewReader((j))) | ||
req.Header.Set(echo.HeaderContentType, echo.MIMEApplicationJSON) | ||
req.Header.Set(echo.HeaderAuthorization, "Bearer "+token.PlainText) | ||
|
||
res := httptest.NewRecorder() | ||
ts.server.ServeHTTP(res, req) | ||
body, err := io.ReadAll(res.Body) | ||
ts.NoError(err) | ||
|
||
// Assertions | ||
ts.Equal(http.StatusOK, res.Code, "incorrect http status, body: \n%s", body) | ||
|
||
var user db.User | ||
ts.NoError(json.Unmarshal(body, &user)) | ||
ts.Equal(input.Email, user.Email, "incorrect user Email, body: \n%s", body) | ||
ts.Equal(tenant.ID, *user.TenantID, "incorrect user TenantID, body: \n%s", body) | ||
|
||
// TODO: test error response | ||
} |