-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Peter Zhu <[email protected]>
- Loading branch information
1 parent
2cfaec1
commit e4ba68a
Showing
5 changed files
with
223 additions
and
129 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* 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. | ||
*/ | ||
import static org.hamcrest.CoreMatchers.notNullValue | ||
import static org.hamcrest.MatcherAssert.assertThat | ||
|
||
class PromoteReposLibTester extends LibFunctionTester { | ||
|
||
private String jobName | ||
private String buildNumber | ||
private String distributionRepoType | ||
|
||
public PromoteReposLibTester(jobName, buildNumber, distributionRepoType) { | ||
this.jobName = jobName | ||
this.buildNumber = buildNumber | ||
this.distributionRepoType = distributionRepoType | ||
} | ||
|
||
void configure(helper, binding){ | ||
binding.setVariable('PUBLIC_ARTIFACT_URL', 'https://ci.opensearch.org/dbc') | ||
binding.setVariable('GITHUB_BOT_TOKEN_NAME', 'github_bot_token_name') | ||
def configs = ["role": "dummy_role", | ||
"external_id": "dummy_ID", | ||
"unsigned_bucket": "dummy_unsigned_bucket", | ||
"signed_bucket": "dummy_signed_bucket"] | ||
binding.setVariable('configs', configs) | ||
helper.addFileExistsMock('/tmp/workspace/sign.sh', true) | ||
helper.registerAllowedMethod("readJSON", [Map.class], {c -> configs}) | ||
helper.registerAllowedMethod("git", [Map]) | ||
helper.registerAllowedMethod("withCredentials", [Map, Closure], { args, closure -> | ||
closure.delegate = delegate | ||
return helper.callClosure(closure) | ||
}) | ||
helper.registerAllowedMethod("withAWS", [Map, Closure], { args, closure -> | ||
closure.delegate = delegate | ||
return helper.callClosure(closure) | ||
}) | ||
} | ||
|
||
void parameterInvariantsAssertions(call){ | ||
assertThat(call.args.jobName.first(), notNullValue()) | ||
assertThat(call.args.buildNumber.first(), notNullValue()) | ||
assertThat(call.args.distributionRepoType.first(), notNullValue()) | ||
} | ||
|
||
boolean expectedParametersMatcher(call) { | ||
return call.args.jobName.first().toString().equals(this.jobName) | ||
&& call.args.buildNumber.first().toString().equals(this.buildNumber) | ||
&& call.args.distributionRepoType.first().toString().equals(this.distributionRepoType) | ||
} | ||
|
||
String libFunctionName() { | ||
return 'promoteRepos' | ||
} | ||
} |
Oops, something went wrong.