package cn.nianxx.thhotel.platform.documentconversion.service.impl;

import java.io.IOException;
import org.junit.jupiter.api.Test;
import org.springframework.boot.env.YamlPropertySourceLoader;
import org.springframework.core.env.PropertySource;
import org.springframework.core.io.ClassPathResource;

class DocumentConversionConfigurationTest {

    @Test
    void shouldAllowProdProfileToStartWithoutDocumentConversionAccessKeyWhenDisabled() throws IOException {
        YamlPropertySourceLoader loader = new YamlPropertySourceLoader();
        PropertySource<?> propertySource = loader.load(
                "application-prod",
                new ClassPathResource("application-prod.yml"))
                .get(0);

        org.assertj.core.api.Assertions.assertThat(propertySource.getProperty("document-conversion.access-key"))
                .isEqualTo("${DOCUMENT_CONVERSION_PROD_ACCESS_KEY:${DOCUMENT_CONVERSION_ACCESS_KEY:}}");
    }
}
