forked from opensearch-project/opensearch-build-libraries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TestPublishToCrates.groovy
48 lines (41 loc) · 1.68 KB
/
TestPublishToCrates.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
/*
* 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.
*/
package jenkins.tests
import jenkins.tests.BuildPipelineTest
import static com.lesfurets.jenkins.unit.MethodCall.callArgsToString
import static org.hamcrest.CoreMatchers.hasItem
import static org.hamcrest.MatcherAssert.assertThat
import org.junit.Before
import org.junit.Test
class TestPublishToCrates extends BuildPipelineTest {
@Test
void testWithoutPackage() {
this.registerLibTester(new PublishToCratesLibTester('https://github.com/opensearch-project/opensearch-rs', '1.0.0'))
super.setUp()
super.testPipeline('tests/jenkins/jobs/PublishToCrates_Jenkinsfile')
assertThat(getCommands('sh', 'cargo'), hasItem('cargo publish --dry-run && cargo publish --token API_TOKEN'))
}
@Test
void testWithPackage() {
this.registerLibTester(new PublishToCratesLibTester('https://github.com/opensearch-project/opensearch-rs', '1.0.0', 'opensearch'))
super.setUp()
super.testPipeline('tests/jenkins/jobs/publishToCratesWithPackage_Jenkinsfile')
assertThat(getCommands('sh', 'cargo'), hasItem('cargo publish -p opensearch --dry-run && cargo publish -p opensearch --token API_TOKEN'))
}
def getCommands(method, text) {
def shCommands = helper.callStack.findAll { call ->
call.methodName == method
}.collect { call ->
callArgsToString(call)
}.findAll { command ->
command.contains(text)
}
return shCommands
}
}