package cn.nianxx.thhotel.platform.debug.service;

import static org.assertj.core.api.Assertions.assertThat;

import cn.nianxx.thhotel.ThHotelApplication;
import cn.nianxx.thhotel.platform.debug.service.impl.DebugEmlSuperAgentProperties;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.web.servlet.MultipartProperties;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;

@SpringBootTest(
        classes = ThHotelApplication.class,
        properties = "debug.eml-upload.max-file-bytes=10485760")
@ActiveProfiles("test")
class DebugEmlMultipartConfigurationTest {

    @Autowired
    private MultipartProperties multipartProperties;

    @Autowired
    private DebugEmlSuperAgentProperties debugEmlProperties;

    @Test
    void shouldLeaveHeadroomForDebugEmlBusinessLimit() {
        assertThat(multipartProperties.getMaxFileSize().toBytes())
                .isGreaterThan(debugEmlProperties.getMaxFileBytes());
        assertThat(multipartProperties.getMaxRequestSize().toBytes())
                .isGreaterThan(debugEmlProperties.getMaxFileBytes());
    }
}
