-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #183 from Devansh-bit/rem-fetchall-mentors
Removed obsolete FetchAllMentors Endpoint
- Loading branch information
Showing
3 changed files
with
0 additions
and
108 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -164,78 +164,6 @@ func TestMentorRegOK(t *testing.T) { | |
) | ||
} | ||
|
||
func createFetchMentorRequest() *http.Request { | ||
req, _ := http.NewRequest( | ||
"GET", | ||
"/mentor/all/", | ||
nil, | ||
) | ||
return req | ||
} | ||
|
||
// Test unauthenticated request to /mentor/all/ | ||
func TestFetchMentorNoAuth(t *testing.T) { | ||
testRequestNoAuth(t, "GET", "/mentor/all/") | ||
} | ||
|
||
// Test request to /mentor/all/ with invalid jwt | ||
func TestFetchMentorInvalidAuth(t *testing.T) { | ||
testRequestInvalidAuth(t, "GET", "/mentor/all/") | ||
} | ||
|
||
func TestFetchMentorOK(t *testing.T) { | ||
const numMentors = 10 | ||
// Set up a local test database path | ||
db := setTestDB() | ||
defer unsetTestDB() | ||
|
||
// Generate a jwt secret key for testing | ||
setTestJwtSecretKey() | ||
defer unsetTestJwtSecretKey() | ||
|
||
// Test login fields | ||
testUsername := getTestUsername() | ||
testLoginFields := utils.LoginJwtFields{Username: testUsername} | ||
|
||
testJwt, _ := utils.GenerateLoginJwtString(testLoginFields) | ||
|
||
modelMentors := make([]models.Mentor, 0, numMentors) | ||
var testMentors [numMentors]controllers.Mentor | ||
for i := 0; i < numMentors; i++ { | ||
modelMentors = append(modelMentors, | ||
models.Mentor{ | ||
Name: fmt.Sprintf("Test%d", i), | ||
Username: fmt.Sprintf("test%d", i), | ||
Email: fmt.Sprintf("test%[email protected]", i), | ||
}) | ||
testMentors[i] = controllers.Mentor{ | ||
Name: fmt.Sprintf("Test%d", i), | ||
Username: fmt.Sprintf("test%d", i), | ||
} | ||
|
||
} | ||
_ = db.Table("mentors").Create(modelMentors) | ||
|
||
req := createFetchMentorRequest() | ||
req.Header.Add("Bearer", testJwt) | ||
|
||
res := executeRequest(req, db) | ||
|
||
var resMentors []controllers.Mentor | ||
_ = json.NewDecoder(res.Body).Decode(&resMentors) | ||
|
||
expectStatusCodeToBe(t, res, http.StatusOK) | ||
if len(resMentors) != numMentors { | ||
t.Fatalf("Not getting expected numbers of mentors from /mentor/all/") | ||
} | ||
|
||
for i, mentor := range resMentors { | ||
if mentor != testMentors[i] { | ||
t.Fatalf("Incorrect mentors returned from /mentor/all/") | ||
} | ||
} | ||
} | ||
|
||
// Test unauthenticated request to /mentor/dashboard/ | ||
func TestMentorDashboardNoAuth(t *testing.T) { | ||
testRequestNoAuth(t, "GET", "/mentor/dashboard/") | ||
|
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