Skip to content

Commit

Permalink
Merge pull request #613 from jonesbusy/feature/test-580
Browse files Browse the repository at this point in the history
Demonstrate test for #580
  • Loading branch information
jonesbusy authored Jan 11, 2025
2 parents d800e48 + 37d69d6 commit 160adeb
Showing 1 changed file with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
import java.util.Set;
import org.intellij.lang.annotations.Language;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.openrewrite.Issue;
import org.openrewrite.java.JavaParser;
import org.openrewrite.test.RewriteTest;
import org.slf4j.Logger;
Expand Down Expand Up @@ -438,6 +440,45 @@ void testWithJenkinsfileOnly() throws Exception {
assertFalse(pluginMetadata.isUseContainerTests());
}

@Test
@Issue("https://github.com/jenkins-infra/plugin-modernizer-tool/issues/580")
@Disabled
void testWithJenkinsfileOnlyShebangAndComment() {
rewriteRun(
recipeSpec -> recipeSpec.recipe(new FetchMetadata()),
// language=groovy
groovy(
"""
#!/usr/bin/env groovy
/* `buildPlugin` step provided by: https://github.com/jenkins-infra/pipeline-library */
buildPlugin(
useContainerAgent: true,
configurations: [
[platform: 'linux', jdk: 21],
[platform: 'windows', jdk: 17],
])
""",
spec -> spec.path("Jenkinsfile")));

PluginMetadata pluginMetadata = new PluginMetadata().refresh();
assertNotNull(pluginMetadata, "Plugin metadata was not written by the recipe");
// Only Jenkinsfile here
assertEquals(List.of(ArchetypeCommonFile.JENKINSFILE), pluginMetadata.getCommonFiles());

// Assert JDK
Set<JDK> jdkVersion = pluginMetadata.getJdks();
assertEquals(2, jdkVersion.size());
assertTrue(pluginMetadata.isUseContainerAgent());

// Assert platform
Set<Platform> platforms = pluginMetadata.getPlatforms();
assertEquals(2, platforms.size());
assertTrue(platforms.contains(Platform.WINDOWS));
assertTrue(platforms.contains(Platform.LINUX));

assertFalse(pluginMetadata.isUseContainerTests());
}

@Test
void testPluginWithJenkinsfileWithJdkInfoConfiguration() {
rewriteRun(
Expand Down

0 comments on commit 160adeb

Please sign in to comment.