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 upgrade tests are valid #1682

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

Check if upgrade tests are valid #1682

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

Comments

@jan-vcapgemini
Copy link
Collaborator

Check:

/**
* Test the correct folder creation
*
* @throws Exception test fails
*/
@Test
@Ignore // TODO: re-enable when upgrader was implemented, see: https://github.com/devonfw/cobigen/issues/1595
public void testTemplateSetUpgrade() throws Exception {
FileUtils.copyDirectory(new File(testFileRootPath + "valid-2.1"), this.currentHome.toFile());
this.templateLocation = this.currentHome.resolve(ConfigurationConstants.TEMPLATES_FOLDER)
.resolve(ConfigurationConstants.COBIGEN_TEMPLATES);
withEnvironmentVariable(ConfigurationConstants.CONFIG_ENV_HOME, this.currentHome.toString()).execute(() -> {
TemplateSetUpgrader templateSetUpgrader = new TemplateSetUpgrader();
templateSetUpgrader.upgradeTemplatesToTemplateSets(this.templateLocation);
Path templateSetsPath = this.templateLocation.getParent().getParent()
.resolve(ConfigurationConstants.TEMPLATE_SETS_FOLDER);
Path backup = this.templateLocation.getParent().getParent().resolve(ConfigurationConstants.BACKUP_FOLDER);
Path templateSetsAdapted = templateSetsPath.resolve(ConfigurationConstants.ADAPTED_FOLDER);
assertThat(templateSetsPath).exists();
assertThat(templateSetsAdapted).exists();
assertThat(backup).exists();
});
}
/**
* Test the correct folder creation
*
* @throws Exception test fails
*/
@Test
public void testTemplateSetUpgradeWithoutTemplatesFolder() throws Exception {
FileUtils.copyDirectory(new File(testFileRootPath + "valid-2.1/templates"), this.currentHome.toFile());
this.templateLocation = this.currentHome.resolve(ConfigurationConstants.COBIGEN_TEMPLATES);
withEnvironmentVariable(ConfigurationConstants.CONFIG_ENV_HOME, this.currentHome.toString()).execute(() -> {
TemplateSetUpgrader templateSetUpgrader = new TemplateSetUpgrader();
templateSetUpgrader.upgradeTemplatesToTemplateSets(this.templateLocation);
Path templateSetsPath = this.templateLocation.getParent().resolve(ConfigurationConstants.TEMPLATE_SETS_FOLDER);
Path templateSetsAdapted = templateSetsPath.resolve(ConfigurationConstants.ADAPTED_FOLDER);
Path backup = this.templateLocation.getParent().resolve(ConfigurationConstants.BACKUP_FOLDER);
assertThat(templateSetsPath).exists();
assertThat(templateSetsAdapted).exists();
assertThat(backup).exists();
});
}

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