mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-12 10:55:20 +02:00
ffc931aad1
* Added unit tag as argument. Added description to runTests command. Changed code generator to have unit build tag in generated unit test files. * Added unit build tag to all unit test files. * added to new unit test unit build tag * Update verify-go.yml * small fix --------- Co-authored-by: Muhammadali Nazarov <Muhammadali.Nazarov@acronis.com> Co-authored-by: Christopher Fenner <26137398+CCFenner@users.noreply.github.com>
43 lines
1.1 KiB
Go
43 lines
1.1 KiB
Go
//go:build unit
|
|
// +build unit
|
|
|
|
package toolrecord_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/SAP/jenkins-library/pkg/mock"
|
|
"github.com/SAP/jenkins-library/pkg/toolrecord"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestToolRecord(t *testing.T) {
|
|
workspace := t.TempDir()
|
|
|
|
t.Run("Check toolrecord", func(t *testing.T) {
|
|
fileMock := mock.FilesMock{}
|
|
tr := toolrecord.New(&fileMock, workspace, "dummyTool", "dummyInstance")
|
|
|
|
_ = tr.AddKeyData("Organization", "dummyOrgId", "dummyOrgName", "dummyOrgUrl")
|
|
_ = tr.AddKeyData("Project", "dummyProjectId", "dummyProjName", "dummyProjUrl")
|
|
_ = tr.AddKeyData("ScanId", "dummyScanId", "dummyScanName", "dummyScanUrl")
|
|
context := map[string]interface{}{
|
|
"demo": "data",
|
|
"anything": struct {
|
|
s1 string
|
|
i1 int
|
|
}{"goes", 42},
|
|
}
|
|
_ = tr.AddContext("DemoContext", context)
|
|
context2 := "a string"
|
|
_ = tr.AddContext("Context2", context2)
|
|
var context3 [2]string
|
|
context3[0] = "c3_1"
|
|
context3[1] = "c3_2"
|
|
_ = tr.AddContext("Context3", context3)
|
|
err := tr.Persist()
|
|
assert.Nil(t, err, "internal error %s")
|
|
assert.True(t, fileMock.HasFile(tr.GetFileName()), "toolrecord not persisted %s")
|
|
})
|
|
}
|