Created
April 5, 2023 11:43
-
-
Save rahogata/77a8723f701eb30387a6edffbcf47963 to your computer and use it in GitHub Desktop.
Create application.yaml for unit tests, avoiding copy of main application.yaml.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
service.doc: | |
dest-directory: file:./service-files | |
temp-dir: file:./service-files/service-temp-dir | |
service.storage.location: ./ssfiles |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.yaml.snakeyaml.Yaml | |
import org.yaml.snakeyaml.DumperOptions | |
task mergeToTestApplicationConfig { | |
InputStream appIns = new File("${projectDir}/src/main/resources/application.yaml").newInputStream() | |
InputStream testIns = new File("${projectDir}/src/test/resources/application-sibling.yaml").newInputStream() | |
InputStream appTestIns = new SequenceInputStream(appIns, testIns); | |
DumperOptions options = new DumperOptions(); | |
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); | |
options.setPrettyFlow(true); | |
Yaml p = new Yaml() | |
def mergedOut = p.load(appTestIns) | |
p.dump(mergedOut, new FileWriter("${projectDir}/src/test/resources/application.yaml")) | |
} | |
tasks.test.dependsOn mergeToTestApplicationConfig |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment