mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-14 11:03:09 +02:00
60b7d3a8df
* refactor(sonar): add initial metadata file for GO-based sonar step * refactor(sonar): add initial generated files for GO-based sonar step * refactor(sonar): add initial step file for GO-based sonar step * refactor(sonar): add sonar cmd to executable * refactor(sonar): cleanup metadata file * fix(go): use capital TLS in golang names * add download of Sonar scanner cli * move download & unzip methods to FileUtils * download certificate files * use http.Downloader * update generated code * add slice prefix function * update sonar step * add test cases * update docs * use node:lts image * use latest sonar-scanner * add test cases * use latest sonar-scanner * fix test case * change things * return errors on functions * limit changeID visibility * use lowercase scm provider * add test case for legacy PRs * add test case * update docs * use local temp dir * extend parameter visibility to GENERAL * use SONAR_AUTH_TOKEN * remove comments * update generated code * Apply suggestions from code review * change to private fields * use setter for sonar options & environment * remove obsolete return statement * add comment about Downloader mock * add test case for custom options * handle custom options * refactor slice functions * fix go fmt * fix generated step code * update docs
43 lines
1.1 KiB
Go
43 lines
1.1 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 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")
|
|
}
|