2018-02-14 12:32:46 +02:00
|
|
|
package com.sap.piper
|
|
|
|
|
2018-01-10 11:27:55 +02:00
|
|
|
import org.junit.Rule
|
2018-02-09 17:34:39 +02:00
|
|
|
import org.junit.Before
|
2019-01-30 13:39:33 +02:00
|
|
|
import org.junit.Ignore
|
2018-01-10 11:27:55 +02:00
|
|
|
import org.junit.Test
|
2018-08-29 10:01:16 +02:00
|
|
|
import static org.junit.Assert.assertThat
|
2018-01-10 11:27:55 +02:00
|
|
|
import org.junit.rules.ExpectedException
|
2018-08-29 10:01:16 +02:00
|
|
|
import org.junit.rules.RuleChain
|
2018-01-10 11:27:55 +02:00
|
|
|
|
2018-08-29 10:01:16 +02:00
|
|
|
import static org.hamcrest.Matchers.containsString
|
|
|
|
import static org.hamcrest.Matchers.hasItem
|
|
|
|
import static org.hamcrest.Matchers.is
|
|
|
|
import static org.hamcrest.Matchers.not
|
|
|
|
|
|
|
|
import util.JenkinsLoggingRule
|
|
|
|
import util.JenkinsShellCallRule
|
|
|
|
import util.BasePiperTest
|
|
|
|
import util.Rules
|
2018-01-10 11:27:55 +02:00
|
|
|
|
2018-08-29 10:01:16 +02:00
|
|
|
import com.sap.piper.Utils
|
2018-01-10 11:27:55 +02:00
|
|
|
|
2018-08-29 10:01:16 +02:00
|
|
|
class UtilsTest extends BasePiperTest {
|
|
|
|
private ExpectedException thrown = ExpectedException.none()
|
2019-01-22 10:22:15 +02:00
|
|
|
private JenkinsLoggingRule loggingRule = new JenkinsLoggingRule(this)
|
2019-01-22 10:19:28 +02:00
|
|
|
private JenkinsShellCallRule shellRule = new JenkinsShellCallRule(this)
|
2018-01-10 11:27:55 +02:00
|
|
|
|
|
|
|
@Rule
|
2018-08-29 10:01:16 +02:00
|
|
|
public RuleChain rules = Rules
|
|
|
|
.getCommonRules(this)
|
|
|
|
.around(thrown)
|
2019-01-22 10:19:28 +02:00
|
|
|
.around(shellRule)
|
2019-01-22 10:22:15 +02:00
|
|
|
.around(loggingRule)
|
2018-02-09 17:34:39 +02:00
|
|
|
|
|
|
|
private parameters
|
2018-01-10 11:27:55 +02:00
|
|
|
|
|
|
|
@Before
|
2018-02-09 17:34:39 +02:00
|
|
|
void setup() {
|
2018-01-10 11:27:55 +02:00
|
|
|
|
2018-02-09 17:34:39 +02:00
|
|
|
parameters = [:]
|
2019-02-11 13:47:15 +02:00
|
|
|
|
2018-01-10 11:27:55 +02:00
|
|
|
}
|
|
|
|
|
2018-08-29 10:01:16 +02:00
|
|
|
@Test
|
2019-01-30 13:39:33 +02:00
|
|
|
void testGenerateSHA1() {
|
|
|
|
def result = utils.generateSha1('ContinuousDelivery')
|
2018-08-29 10:01:16 +02:00
|
|
|
// asserts
|
2019-01-30 13:39:33 +02:00
|
|
|
// generated with "echo -n 'ContinuousDelivery' | sha1sum | sed 's/ -//'"
|
|
|
|
assertThat(result, is('0dad6c33b6246702132454f604dee80740f399ad'))
|
2018-08-29 10:01:16 +02:00
|
|
|
}
|
2019-02-11 13:47:15 +02:00
|
|
|
|
|
|
|
@Test
|
|
|
|
void testUnstashAllSkipNull() {
|
|
|
|
|
|
|
|
def stashResult = utils.unstashAll(['a', null, 'b'])
|
|
|
|
assert stashResult == ['a', 'b']
|
|
|
|
}
|
2018-01-10 11:27:55 +02:00
|
|
|
}
|