cleanup tests
All checks were successful
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Successful in 1m16s
All checks were successful
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Successful in 1m16s
This commit is contained in:
@ -1,12 +1,12 @@
|
||||
package cc.fascinated.tests;
|
||||
|
||||
import cc.fascinated.config.TestRedisConfig;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import cc.fascinated.config.TestRedisConfig;
|
||||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||
@ -16,21 +16,24 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
@SpringBootTest(classes = TestRedisConfig.class)
|
||||
class ServerControllerTests {
|
||||
|
||||
private final String testServer = "play.hypixel.net";
|
||||
private final String testInvalidServer = "invalidhostnamehahahahahayesslmaooo";
|
||||
|
||||
@Autowired
|
||||
private MockMvc mockMvc;
|
||||
|
||||
@Test
|
||||
public void ensureServerLookupSuccess() throws Exception {
|
||||
mockMvc.perform(get("/server/java/play.hypixel.net")
|
||||
mockMvc.perform(get("/server/java/" + testServer)
|
||||
.accept(MediaType.APPLICATION_JSON)
|
||||
.contentType(MediaType.APPLICATION_JSON))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.server.hostname").value("play.hypixel.net"));
|
||||
.andExpect(jsonPath("$.server.hostname").value(testServer));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ensureServerLookupFailure() throws Exception {
|
||||
mockMvc.perform(get("/server/java/invalidhostnamehahahahahayesslmaooo")
|
||||
mockMvc.perform(get("/server/java/" + testInvalidServer)
|
||||
.accept(MediaType.APPLICATION_JSON)
|
||||
.contentType(MediaType.APPLICATION_JSON))
|
||||
.andExpect(status().isBadRequest());
|
||||
@ -38,14 +41,14 @@ class ServerControllerTests {
|
||||
|
||||
@Test
|
||||
public void ensureServerIconLookupSuccess() throws Exception {
|
||||
mockMvc.perform(get("/server/icon/play.hypixel.net")
|
||||
mockMvc.perform(get("/server/icon/" + testServer)
|
||||
.contentType(MediaType.IMAGE_PNG))
|
||||
.andExpect(status().isOk());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ensureBlockedServerLookupSuccess() throws Exception {
|
||||
mockMvc.perform(get("/server/blocked/play.hypixel.net")
|
||||
mockMvc.perform(get("/server/blocked/" + testServer)
|
||||
.accept(MediaType.APPLICATION_JSON)
|
||||
.contentType(MediaType.APPLICATION_JSON))
|
||||
.andExpect(status().isOk())
|
||||
|
Reference in New Issue
Block a user