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>
77 lines
1.9 KiB
Go
77 lines
1.9 KiB
Go
//go:build integration
|
|
// +build integration
|
|
|
|
package main
|
|
|
|
import (
|
|
"io"
|
|
"io/ioutil"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/SAP/jenkins-library/pkg/generator/helper"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestCommandContract(t *testing.T) {
|
|
assert.Equal(t, "", "")
|
|
}
|
|
|
|
// Test provided by consumer: SAP InnerSource project
|
|
// Changes to the test require peer review by core-team members involved in the project.
|
|
func TestGenerator(t *testing.T) {
|
|
dir := t.TempDir()
|
|
|
|
metadata := `metadata:
|
|
name: test
|
|
description: testDescription
|
|
longDescription: testLongDescription
|
|
spec:
|
|
inputs:
|
|
secrets:
|
|
- name: secret
|
|
description: secretDescription
|
|
type: jenkins
|
|
params:
|
|
- name: testParam
|
|
aliases:
|
|
- name: testAlias
|
|
type: string
|
|
description: The name of the Checkmarx project to scan into
|
|
mandatory: true
|
|
scope:
|
|
- PARAMETERS
|
|
- STAGES
|
|
- STEPS
|
|
resourceRef:
|
|
- name: commonPipelineEnvironment
|
|
param: test/test
|
|
outputs:
|
|
resources:
|
|
- name: influx
|
|
type: influx
|
|
params:
|
|
- name: test_influx
|
|
fields:
|
|
- name: testfield
|
|
- name: commonPipelineEnvironment
|
|
type: piperEnvironment
|
|
params:
|
|
- name: test_cpe
|
|
`
|
|
|
|
ioutil.WriteFile(filepath.Join(dir, "test.yaml"), []byte(metadata), 0755)
|
|
|
|
openMetaFile := func(name string) (io.ReadCloser, error) { return os.Open(name) }
|
|
fileWriter := func(filename string, data []byte, perm os.FileMode) error { return nil }
|
|
|
|
stepHelperData := helper.StepHelperData{OpenFile: openMetaFile, WriteFile: fileWriter, ExportPrefix: "piperOsCmd"}
|
|
|
|
metadataFiles, err := helper.MetadataFiles(dir)
|
|
assert.NoError(t, err)
|
|
|
|
err = helper.ProcessMetaFiles(metadataFiles, "./cmd", stepHelperData)
|
|
assert.NoError(t, err)
|
|
}
|