forked from opensearch-project/opensearch-build-libraries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PublishToNpmLibTester.groovy
45 lines (38 loc) · 1.39 KB
/
PublishToNpmLibTester.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
/*
* 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 PublishToNpmLibTester extends LibFunctionTester {
private String publicationType
private String artifactPath = ''
private List allowedpubs = ['github', 'artifact']
public PublishToNpmLibTester(publicationType) {
this.publicationType = publicationType
}
public PublishToNpmLibTester(publicationType, artifactPath) {
this.publicationType = publicationType
this.artifactPath = artifactPath
}
void configure(helper, binding) {
helper.registerAllowedMethod("checkout", [Map], {})
helper.registerAllowedMethod("withCredentials", [Map, Closure], { args, closure ->
closure.delegate = delegate
return helper.callClosure(closure)
})
}
void parameterInvariantsAssertions(call) {
assertThat(call.args.publicationType.first(), notNullValue())
}
boolean expectedParametersMatcher(call) {
return allowedpubs.contains(call.args.publicationType.first().toString())
}
String libFunctionName() {
return 'publishToNpm'
}
}