Skip to content

Commit

Permalink
Some cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
brianseeders committed Jun 8, 2020
1 parent 64c081e commit f986469
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
1 change: 1 addition & 0 deletions .ci/pipeline-library/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
## Running tests

```bash
cd .ci/pipeline-library
./gradlew test
```
26 changes: 15 additions & 11 deletions .ci/pipeline-library/src/test/KibanaBasePipelineTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ class KibanaBasePipelineTest extends BasePipelineTest {
Map params = [:]

public def Mocks = [
TEST_FAILURE_URL: "https://localhost/",
TEST_FAILURE_NAME: "Kibana Pipeline / kibana-xpack-agent / Chrome X-Pack UI Functional Tests.x-pack/test/functional/apps/fake/test·ts.Fake test <Component> should & pass &",
TEST_FAILURE_URL: 'https://localhost/',
TEST_FAILURE_NAME: 'Kibana Pipeline / kibana-xpack-agent / Chrome X-Pack UI Functional Tests.x-pack/test/functional/apps/fake/test·ts.Fake test <Component> should & pass &',
]

@Before
Expand All @@ -28,7 +28,7 @@ class KibanaBasePipelineTest extends BasePipelineTest {

props([
buildUtils: [
getBuildStatus: { "SUCCESS" },
getBuildStatus: { 'SUCCESS' },
printStacktrace: { ex -> print ex },
],
jenkinsApi: [ getFailedSteps: { [] } ],
Expand All @@ -40,11 +40,15 @@ class KibanaBasePipelineTest extends BasePipelineTest {
params: params,
])

['withGithubCredentials'].each {
// Some wrappers that can just be mocked to immediately call the closure passed in
[
'catchError',
'catchErrors',
'timestamps',
'withGithubCredentials',
].each {
helper.registerAllowedMethod(it, [Closure.class], null)
}

helper.registerAllowedMethod('slackSend', [Map.class], null)
}

void props(Map properties) {
Expand Down Expand Up @@ -74,17 +78,17 @@ class KibanaBasePipelineTest extends BasePipelineTest {
void mockFailureBuild() {
props([
buildUtils: [
getBuildStatus: { "FAILURE" },
getBuildStatus: { 'FAILURE' },
printStacktrace: { ex -> print ex },
],
jenkinsApi: [ getFailedSteps: { [
[
displayName: "Check out from version control",
logs: "http://jenkins.localhost:8080",
displayName: 'Check out from version control',
logs: 'http://jenkins.localhost:8080',
],
[
displayName: "Execute test task",
logs: "http://jenkins.localhost:8080",
displayName: 'Execute test task',
logs: 'http://jenkins.localhost:8080',
],
] } ],
testUtils: [
Expand Down
9 changes: 5 additions & 4 deletions .ci/pipeline-library/src/test/slackNotifications.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ class SlackNotificationsTest extends KibanaBasePipelineTest {
void setUp() {
super.setUp()

slackNotifications = loadScript("vars/slackNotifications.groovy")
helper.registerAllowedMethod('slackSend', [Map.class], null)
slackNotifications = loadScript('vars/slackNotifications.groovy')
}

@Test
Expand All @@ -32,9 +33,9 @@ class SlackNotificationsTest extends KibanaBasePipelineTest {
def args = fnMock('slackSend').args[0]

def expected = [
channel: "#kibana-operations-alerts",
username: "Kibana Operations",
iconEmoji: ":jenkins:",
channel: '#kibana-operations-alerts',
username: 'Kibana Operations',
iconEmoji: ':jenkins:',
color: 'danger',
message: ':broken_heart: elastic / kibana # master #1',
]
Expand Down

0 comments on commit f986469

Please sign in to comment.