Skip to content

Commit

Permalink
Added Tests to Feature 13
Browse files Browse the repository at this point in the history
  • Loading branch information
efentress2025 committed Dec 6, 2023
1 parent 2d798eb commit ebef751
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions app/src/test/java/cse/gradle/Feature13Tests.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,39 @@
class Feature13Tests extends HTTPServerTests{
/* --------------------------------- UNIT TESTS --------------------------------- */
@Test
void checkServerError() {
void checkLoginError() {
Server.stopServer();

// Check for login error
Model model = new MockModel();
String response = model.performLoginRequest("test_user", "password");
String error = "Error: Server down";
assertEquals(error, response);
}

@Test
void checkRecipeError() {
Server.stopServer();

// Check for generic request error
Model model = new MockModel();
Recipe originalRecipe = new Recipe("potatoes", "boil the potatoes", "brunch", "boiled potatoes");
response = model.postRecipe(originalRecipe);
error = "Error: Server down";
String response = model.postRecipe(originalRecipe);
String error = "Error: Server down";
assertEquals(error, response);
}

/* --------------------------------- BDD TESTS --------------------------------- */
@Test
void completeServerErrorTest() {
// login with test user
Model model = new MockModel();
String retrievedUserId = model.performLoginRequest("test_user", "password");
assertEquals(MockModel.mockUserId, retrievedUserId);

// cut connection and ask for recipe
Server.stopServer();
Recipe originalRecipe = new Recipe("potatoes", "boil the potatoes", "brunch", "boiled potatoes");
String response = model.postRecipe(originalRecipe);
String error = "Error: Server down";
assertEquals(error, response);
}
}

0 comments on commit ebef751

Please sign in to comment.