-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 Return and Updates Tickers for Users
- Loading branch information
1 parent
4592ab5
commit 3b25247
Showing
10 changed files
with
264 additions
and
92 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,13 @@ func TestUsersResponse(t *testing.T) { | |
CreatedAt: time.Now(), | ||
Email: "[email protected]", | ||
IsSuperAdmin: true, | ||
Tickers: []storage.Ticker{ | ||
{ | ||
ID: 1, | ||
Domain: "example.com", | ||
Title: "Example", | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
|
@@ -24,4 +31,8 @@ func TestUsersResponse(t *testing.T) { | |
assert.Equal(t, users[0].CreatedAt, usersResponse[0].CreatedAt) | ||
assert.Equal(t, users[0].Email, usersResponse[0].Email) | ||
assert.Equal(t, users[0].IsSuperAdmin, usersResponse[0].IsSuperAdmin) | ||
assert.Equal(t, 1, len(usersResponse[0].Tickers)) | ||
assert.Equal(t, users[0].Tickers[0].ID, usersResponse[0].Tickers[0].ID) | ||
assert.Equal(t, users[0].Tickers[0].Domain, usersResponse[0].Tickers[0].Domain) | ||
assert.Equal(t, users[0].Tickers[0].Title, usersResponse[0].Tickers[0].Title) | ||
} |
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 |
---|---|---|
|
@@ -23,7 +23,7 @@ func TestGetUsersStorageError(t *testing.T) { | |
c, _ := gin.CreateTestContext(w) | ||
c.Set("me", storage.User{IsSuperAdmin: true}) | ||
s := &storage.MockStorage{} | ||
s.On("FindUsers").Return([]storage.User{}, errors.New("storage error")) | ||
s.On("FindUsers", mock.Anything).Return([]storage.User{}, errors.New("storage error")) | ||
h := handler{ | ||
storage: s, | ||
config: config.NewConfig(), | ||
|
@@ -39,7 +39,7 @@ func TestGetUsers(t *testing.T) { | |
c, _ := gin.CreateTestContext(w) | ||
c.Set("me", storage.User{IsSuperAdmin: true}) | ||
s := &storage.MockStorage{} | ||
s.On("FindUsers").Return([]storage.User{}, nil) | ||
s.On("FindUsers", mock.Anything).Return([]storage.User{}, nil) | ||
|
||
h := handler{ | ||
storage: s, | ||
|
@@ -89,7 +89,7 @@ func TestGetUserStorageError(t *testing.T) { | |
c.Set("me", storage.User{ID: 1, IsSuperAdmin: true}) | ||
|
||
s := &storage.MockStorage{} | ||
s.On("FindUserByID", mock.Anything).Return(storage.User{}, errors.New("storage error")) | ||
s.On("FindUserByID", mock.Anything, mock.Anything).Return(storage.User{}, errors.New("storage error")) | ||
h := handler{ | ||
storage: s, | ||
config: config.NewConfig(), | ||
|
@@ -267,7 +267,7 @@ func TestPutUserStorageError(t *testing.T) { | |
c, _ := gin.CreateTestContext(w) | ||
c.Set("me", storage.User{ID: 1, IsSuperAdmin: true}) | ||
c.Set("user", storage.User{}) | ||
json := `{"email":"[email protected]","password":"password1234","isSuperAdmin":true,"tickers":[1]}` | ||
json := `{"email":"[email protected]","password":"password1234","isSuperAdmin":true,"tickers":[{"id":1}]}` | ||
c.Request = httptest.NewRequest(http.MethodPost, "/v1/admin/users", strings.NewReader(json)) | ||
c.Request.Header.Add("Content-Type", "application/json") | ||
s := &storage.MockStorage{} | ||
|
@@ -288,7 +288,7 @@ func TestPutUserStorageError2(t *testing.T) { | |
c, _ := gin.CreateTestContext(w) | ||
c.Set("me", storage.User{ID: 1, IsSuperAdmin: true}) | ||
c.Set("user", storage.User{}) | ||
json := `{"email":"[email protected]","password":"password1234","isSuperAdmin":true,"tickers":[1]}` | ||
json := `{"email":"[email protected]","password":"password1234","isSuperAdmin":true,"tickers":[{"id":1}]}` | ||
c.Request = httptest.NewRequest(http.MethodPost, "/v1/admin/users", strings.NewReader(json)) | ||
c.Request.Header.Add("Content-Type", "application/json") | ||
s := &storage.MockStorage{} | ||
|
@@ -309,7 +309,7 @@ func TestPutUser(t *testing.T) { | |
c, _ := gin.CreateTestContext(w) | ||
c.Set("me", storage.User{ID: 1, IsSuperAdmin: true}) | ||
c.Set("user", storage.User{}) | ||
json := `{"email":"[email protected]","password":"password1234","isSuperAdmin":true,"tickers":[1]}` | ||
json := `{"email":"[email protected]","password":"password1234","isSuperAdmin":true,"tickers":[{"id":1}]}` | ||
c.Request = httptest.NewRequest(http.MethodPost, "/v1/admin/users", strings.NewReader(json)) | ||
c.Request.Header.Add("Content-Type", "application/json") | ||
s := &storage.MockStorage{} | ||
|
Oops, something went wrong.