-
Notifications
You must be signed in to change notification settings - Fork 272
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extracted common test code into a BuildPipelineTest base class. (#979)
Signed-off-by: dblock <dblock@amazon.com>
- Loading branch information
Showing
7 changed files
with
78 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package jenkins.tests | ||
|
||
import org.junit.* | ||
import java.util.* | ||
import static com.lesfurets.jenkins.unit.global.lib.LibraryConfiguration.library | ||
import static com.lesfurets.jenkins.unit.global.lib.ProjectSource.projectSource | ||
import com.lesfurets.jenkins.unit.* | ||
import com.lesfurets.jenkins.unit.declarative.* | ||
import static org.junit.Assert.* | ||
import org.yaml.snakeyaml.Yaml | ||
|
||
abstract class BuildPipelineTest extends DeclarativePipelineTest { | ||
@Override | ||
@Before | ||
void setUp() { | ||
super.setUp() | ||
|
||
helper.registerSharedLibrary( | ||
library().name('jenkins') | ||
.defaultVersion('<notNeeded>') | ||
.allowOverride(true) | ||
.implicit(true) | ||
.targetPath('<notNeeded>') | ||
.retriever(projectSource()) | ||
.build() | ||
) | ||
|
||
helper.registerAllowedMethod("readYaml", [Map.class], { args -> | ||
return new Yaml().load((args.file as File).text) | ||
}) | ||
|
||
binding.setVariable('scm', {}) | ||
|
||
helper.registerAllowedMethod("legacySCM", [Closure.class], null) | ||
|
||
helper.registerAllowedMethod("library", [Map.class], { Map args -> | ||
helper.getLibLoader().loadLibrary(args["identifier"]) | ||
return new LibClassLoader(helper, null) | ||
}) | ||
} | ||
|
||
void testPipeline(String jenkinsScript) { | ||
runScript(jenkinsScript) | ||
RegressionTestHelper.testNonRegression(helper, jenkinsScript) | ||
assertJobStatusSuccess() | ||
printCallStack() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters