Skip to content

Check if upgrade tests are valid #1682

@jan-vcapgemini

Description

@jan-vcapgemini

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();
});
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions