Skip to content

Commit

Permalink
Add ignored tests for Jenkinsfile recipes
Browse files Browse the repository at this point in the history
  • Loading branch information
sghill committed Aug 15, 2023
1 parent f3df02e commit cee9cd4
Show file tree
Hide file tree
Showing 2 changed files with 136 additions and 0 deletions.
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ dependencies {

testImplementation("org.openrewrite:rewrite-test")
testImplementation("org.openrewrite:rewrite-java-tck")
testImplementation("org.openrewrite:rewrite-groovy")
testImplementation("org.assertj:assertj-core:latest.release")

testRuntimeOnly("com.github.spotbugs:spotbugs-annotations:4.7.0")
Expand Down
135 changes: 135 additions & 0 deletions src/test/java/org/openrewrite/jenkins/ModernizeJenkinsfileTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@
*/
package org.openrewrite.jenkins;

import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.openrewrite.DocumentExample;
import org.openrewrite.Recipe;
import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.RewriteTest;

import static org.openrewrite.groovy.Assertions.groovy;
import static org.openrewrite.maven.Assertions.pomXml;
import static org.openrewrite.test.SourceSpecs.text;

Expand Down Expand Up @@ -100,4 +103,136 @@ void shouldUpdateJenkinsfile() {
""".stripIndent(),
spec -> spec.path("Jenkinsfile")));
}

@Test
@Disabled
void shouldAddJdk21IfAbsent() {
rewriteRun(spec -> spec.recipe(new AddBuildPluginConfiguration("linux", "21")),
groovy("""
buildPlugin()
""".stripIndent(), """
buildPlugin(configurations:[
[ platform: 'linux', jdk: '21' ]
])
""".stripIndent(),
spec -> spec.path("Jenkinsfile")
));
}

@Test
@Disabled
void shouldRemoveJdk8IfPresent() {
rewriteRun(spec -> spec.recipe(new RemoveBuildPluginConfiguration("linux", "8")),
groovy("""
buildPlugin(useContainerAgent: true, configurations: [
[ platform: 'linux', jdk: '8' ],
[ platform: 'windows', jdk: '8' ],
[ platform: 'windows', jdk: '11' ],
[ platform: 'linux', jdk: '17' ],
])
""".stripIndent(), """
buildPlugin(useContainerAgent: true, configurations: [
[ platform: 'windows', jdk: '8' ],
[ platform: 'windows', jdk: '11' ],
[ platform: 'linux', jdk: '17' ],
])
""".stripIndent(),
spec -> spec.path("Jenkinsfile")
));
}

@Test
@Disabled
void shouldRemoveJdk8FromAllPlatformsIfPresent() {
rewriteRun(spec -> spec.recipe(new RemoveBuildPluginConfiguration("8")),
groovy("""
buildPlugin(useContainerAgent: true, failFast: false, configurations: [
[ platform: 'linux', jdk: '8' ],
[ platform: 'windows', jdk: '8' ],
[ platform: 'windows', jdk: '11' ],
[ platform: 'linux', jdk: '17' ],
])
""".stripIndent(), """
buildPlugin(useContainerAgent: true, failFast: false, configurations: [
[ platform: 'windows', jdk: '11' ],
[ platform: 'linux', jdk: '17' ],
])
""".stripIndent(),
spec -> spec.path("Jenkinsfile")
));
}

@Test
@Disabled
void shouldRemoveJenkinsVersionsLessThan() {
rewriteRun(spec -> spec.recipe(new RemoveJenkinsVersionsLessThan("2.346.3")),
groovy("""
buildPlugin(jenkinsVersions: [null, '2.60.1', '2.387.3'])
""".stripIndent(), """
buildPlugin(jenkinsVersions: [null, '2.387.3'])
""".stripIndent(),
spec -> spec.path("Jenkinsfile")
));
}

@Test
@Disabled
void shouldRemoveKeyIfRemoveJenkinsVersionsLessThanLeavesOnlyNull() {
rewriteRun(spec -> spec.recipe(new RemoveJenkinsVersionsLessThan("2.346.3")),
groovy("""
buildPlugin(jenkinsVersions: [null, '2.60.1'])
""".stripIndent(), """
buildPlugin()
""".stripIndent(),
spec -> spec.path("Jenkinsfile")
));
}

private static class AddBuildPluginConfiguration extends Recipe {
public AddBuildPluginConfiguration(String platform, String jdk) {
}

@Override
public String getDisplayName() {
return null;
}

@Override
public String getDescription() {
return null;
}
}

private static class RemoveBuildPluginConfiguration extends Recipe {
public RemoveBuildPluginConfiguration(String jdk) {
}

public RemoveBuildPluginConfiguration(String platform, String jdk) {
}

@Override
public String getDisplayName() {
return null;
}

@Override
public String getDescription() {
return null;
}
}

private class RemoveJenkinsVersionsLessThan extends Recipe {
public RemoveJenkinsVersionsLessThan(String version) {
}

@Override
public String getDisplayName() {
return null;
}

@Override
public String getDescription() {
return null;
}
}
}

0 comments on commit cee9cd4

Please sign in to comment.