mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-14 11:03:09 +02:00
c190deee44
* use sonar go in groovy * use SONAR_TOKEN * only use owner/repo if both are set * trim version to major version digit * fix code climate issues * remove Sonar defaults * use sonar go step * use SONAR_TOKEN * use certs from parameters * use docker workspace & options * add instance parameter * implement branchName * implement branchName * remove duplicate default * update docs * fix TODOs * remove merge mess * fix code climate issue * address comments * respect custom defaults and custom config file name * fix typo * remove obsolete test cases * disable CommonStepChecks * check step config instead of context config * remove TODOs * respect jenkins PR envvars * use value from stepConfig * Update vars/sonarExecuteScan.groovy * rename options to config * correct type for options * add test cases * log sonar.options in debug message Co-authored-by: Oliver Nocon <33484802+OliverNocon@users.noreply.github.com>
54 lines
1.4 KiB
Go
54 lines
1.4 KiB
Go
package piperutils
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestContainsInt(t *testing.T) {
|
|
var intList []int
|
|
assert.Equal(t, false, ContainsInt(intList, 4), "False expected but returned true")
|
|
|
|
intList = append(intList, 1, 2, 3, 4, 5, 6, 20)
|
|
assert.Equal(t, true, ContainsInt(intList, 20), "True expected but returned false")
|
|
assert.Equal(t, true, ContainsInt(intList, 1), "True expected but returned false")
|
|
assert.Equal(t, true, ContainsInt(intList, 4), "True expected but returned false")
|
|
assert.Equal(t, false, ContainsInt(intList, 13), "False expected but returned true")
|
|
}
|
|
|
|
func TestPrefix(t *testing.T) {
|
|
// init
|
|
s := []string{"tree", "pie", "applejuice"}
|
|
// test
|
|
s = Prefix(s, "apple")
|
|
// assert
|
|
assert.Contains(t, s, "appletree")
|
|
assert.Contains(t, s, "applepie")
|
|
assert.Contains(t, s, "appleapplejuice")
|
|
}
|
|
|
|
func TestPrefixIfNeeded(t *testing.T) {
|
|
// init
|
|
s := []string{"tree", "pie", "applejuice"}
|
|
// test
|
|
s = PrefixIfNeeded(s, "apple")
|
|
// assert
|
|
assert.Contains(t, s, "appletree")
|
|
assert.Contains(t, s, "applepie")
|
|
assert.Contains(t, s, "applejuice")
|
|
}
|
|
|
|
func TestTrim(t *testing.T) {
|
|
// init
|
|
s := []string{" orange", "banana ", " apple", "mango ", " ", ""}
|
|
// test
|
|
s = Trim(s)
|
|
// assert
|
|
assert.Equal(t, 4, len(s))
|
|
assert.Contains(t, s, "orange")
|
|
assert.Contains(t, s, "banana")
|
|
assert.Contains(t, s, "apple")
|
|
assert.Contains(t, s, "mango")
|
|
}
|