package services | |
import org.springframework.beans.factory.annotation.Autowired | |
import org.springframework.boot.test.context.SpringBootTest | |
import org.springframework.boot.test.web.client.TestRestTemplate | |
import org.springframework.mock.web.MockMultipartFile | |
import org.springframework.test.context.ContextConfiguration | |
import spock.lang.Specification | |
@ContextConfiguration | |
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) | |
class FileUploadControllerTest extends Specification { | |
@Autowired | |
private TestRestTemplate restTemplate | |
def "test loading a empyt file"(){ | |
when: "give a empyt file to load" | |
MockMultipartFile multipartFile = new MockMultipartFile("file", "test.txt", "text/plain", "Please select a file to upload".getBytes()) | |
String requestResult = restTemplate.postForObject("/uploadFile",multipartFile,String.class) | |
then: "return a error message" | |
requestResult.contains("Please select a file to upload") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment