forked from opensearch-project/opensearch-build-libraries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PublishToNugetLibTester.groovy
55 lines (49 loc) · 2.21 KB
/
PublishToNugetLibTester.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
* 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 PublishToNugetLibTester extends LibFunctionTester {
private String repository
private String tag
private String apiKeyCredentialId
private String solutionFilePath
public PublishToNugetLibTester(repository, tag, apiKeyCredentialId, solutionFilePath) {
this.repository = repository
this.tag = tag
this.apiKeyCredentialId = apiKeyCredentialId
this.solutionFilePath = solutionFilePath
}
void configure(helper, binding){
helper.registerAllowedMethod("checkout", [Map], {})
binding.setVariable('GITHUB_BOT_TOKEN_NAME', 'github_bot_token_name')
helper.registerAllowedMethod('git', [Map])
helper.addFileExistsMock('/tmp/workspace/sign.sh', false)
helper.addReadFileMock('/tmp/workspace/dlls.txt', 'one.dll \n two.dll \n three.dll')
helper.addReadFileMock('/tmp/workspace/nupkg.txt', 'src/net/one.nupkg \n src/net/two.nupkg \n src/net/three.nupkg')
helper.registerAllowedMethod("withCredentials", [Map, Closure], { args, closure ->
closure.delegate = delegate
return helper.callClosure(closure)
})
}
void parameterInvariantsAssertions(call){
assertThat(call.args.repository.first(), notNullValue())
assertThat(call.args.tag.first(), notNullValue())
assertThat(call.args.apiKeyCredentialId.first(), notNullValue())
assertThat(call.args.solutionFilePath.first(), notNullValue())
}
boolean expectedParametersMatcher(call) {
return call.args.repository.first().toString().equals(this.repository)
&& call.args.tag.first().toString().equals(this.tag)
&& call.args.apiKeyCredentialId.first().toString().equals(this.apiKeyCredentialId)
&& call.args.solutionFilePath.first().toString().equals(this.solutionFilePath)
}
String libFunctionName() {
return 'publishToNuget'
}
}