Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if tests can be removed/combined #1672

Open
jan-vcapgemini opened this issue Apr 5, 2023 · 0 comments
Open

Check if tests can be removed/combined #1672

jan-vcapgemini opened this issue Apr 5, 2023 · 0 comments

Comments

@jan-vcapgemini
Copy link
Collaborator

Check if TemplatesInstallationTests and DownloadTemplateSetTests can be combined and if the tests need to be overhauled.

/**
* Tests if the templates specified in the .cobigen file will be loaded at startup with the template-set structure and
* an existing downloaded folder.
*
* TODO: Check if this test is valid
*
* @throws Exception test fails.
*/
@Test
public void testInstallTemplatesAtStartup() throws Exception {
File folder = this.tmpFolder.newFolder("TemplateSetsInstalledTest");
withEnvironmentVariable(ConfigurationConstants.CONFIG_ENV_HOME, folder.getAbsolutePath()).execute(() -> {
File templateSets = this.tmpFolder.newFolder("TemplateSetsInstalledTest",
ConfigurationConstants.TEMPLATE_SETS_FOLDER);
File downloaded = this.tmpFolder.newFolder("TemplateSetsInstalledTest",
ConfigurationConstants.TEMPLATE_SETS_FOLDER, "downloaded");
File target = new File(folder, ConfigurationConstants.COBIGEN_CONFIG_FILE);
try (BufferedWriter writer = new BufferedWriter(new FileWriter(target))) {
writer.write(
"template-sets.installed=com.devonfw.cobigen.templates:crud-openapi-angular-client-app:2021.12.007-SNAPSHOT");
}
CobiGenFactory.create(templateSets.toURI());
assertThat(downloaded.listFiles()).hasSize(2);
});
}

/**
* Tests if a template set SNAPSHOT defined in properties template-sets.installed can be retrieved and downloaded from
* sonatype
*
* @throws Exception test fails
*/
@Test
public void testDownloadTemplateSetWithProperty() throws Exception {
File folder = this.tmpFolder.newFolder("DownloadTemplatesetsTest");
File target = new File(folder, ConfigurationConstants.COBIGEN_CONFIG_FILE);
try (BufferedWriter writer = new BufferedWriter(new FileWriter(target))) {
writer.write(
"template-sets.installed=com.devonfw.cobigen.templates:crud-openapi-angular-client-app:2021.12.007-SNAPSHOT");
}
Path templateSetFolder = Files
.createDirectories(folder.toPath().resolve(ConfigurationConstants.TEMPLATE_SETS_FOLDER));
withEnvironmentVariable(ConfigurationConstants.CONFIG_ENV_HOME, folder.getAbsolutePath()).execute(() -> {
CobiGenFactory.create(templateSetFolder.toUri(), false);
});
Path downloadedFolder = templateSetFolder.resolve(ConfigurationConstants.DOWNLOADED_FOLDER);
assertThat(downloadedFolder).exists();
assertThat(downloadedFolder.toFile().listFiles()).hasSize(2);
}

@jan-vcapgemini jan-vcapgemini changed the title Check if tests can be removed Check if tests can be removed/combined Apr 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant