mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-14 11:03:09 +02:00
59 lines
1.5 KiB
Groovy
59 lines
1.5 KiB
Groovy
package com.sap.piper
|
|
|
|
import org.junit.Rule
|
|
import org.junit.Before
|
|
import org.junit.Ignore
|
|
import org.junit.Test
|
|
import static org.junit.Assert.assertThat
|
|
import org.junit.rules.ExpectedException
|
|
import org.junit.rules.RuleChain
|
|
|
|
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
|
|
|
|
import com.sap.piper.Utils
|
|
|
|
class UtilsTest extends BasePiperTest {
|
|
private ExpectedException thrown = ExpectedException.none()
|
|
private JenkinsLoggingRule loggingRule = new JenkinsLoggingRule(this)
|
|
private JenkinsShellCallRule shellRule = new JenkinsShellCallRule(this)
|
|
|
|
@Rule
|
|
public RuleChain rules = Rules
|
|
.getCommonRules(this)
|
|
.around(thrown)
|
|
.around(shellRule)
|
|
.around(loggingRule)
|
|
|
|
private parameters
|
|
|
|
@Before
|
|
void setup() {
|
|
|
|
parameters = [:]
|
|
|
|
}
|
|
|
|
@Test
|
|
void testGenerateSHA1() {
|
|
def result = utils.generateSha1('ContinuousDelivery')
|
|
// asserts
|
|
// generated with "echo -n 'ContinuousDelivery' | sha1sum | sed 's/ -//'"
|
|
assertThat(result, is('0dad6c33b6246702132454f604dee80740f399ad'))
|
|
}
|
|
|
|
@Test
|
|
void testUnstashAllSkipNull() {
|
|
|
|
def stashResult = utils.unstashAll(['a', null, 'b'])
|
|
assert stashResult == ['a', 'b']
|
|
}
|
|
}
|