2023-05-03 18:02:11 +02:00
|
|
|
//go:build integration
|
|
|
|
// +build integration
|
|
|
|
|
2020-02-18 16:19:50 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
"testing"
|
2020-07-17 08:06:11 +02:00
|
|
|
|
|
|
|
"github.com/SAP/jenkins-library/pkg/generator/helper"
|
|
|
|
"github.com/stretchr/testify/assert"
|
2020-02-18 16:19:50 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
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) {
|
2022-07-12 15:19:12 +02:00
|
|
|
dir := t.TempDir()
|
2020-02-18 16:19:50 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
`
|
|
|
|
|
2023-08-16 12:57:04 +02:00
|
|
|
os.WriteFile(filepath.Join(dir, "test.yaml"), []byte(metadata), 0755)
|
2020-02-18 16:19:50 +02:00
|
|
|
|
|
|
|
openMetaFile := func(name string) (io.ReadCloser, error) { return os.Open(name) }
|
|
|
|
fileWriter := func(filename string, data []byte, perm os.FileMode) error { return nil }
|
|
|
|
|
2020-09-23 13:55:17 +02:00
|
|
|
stepHelperData := helper.StepHelperData{OpenFile: openMetaFile, WriteFile: fileWriter, ExportPrefix: "piperOsCmd"}
|
2020-02-18 16:19:50 +02:00
|
|
|
|
|
|
|
metadataFiles, err := helper.MetadataFiles(dir)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
2020-09-23 13:55:17 +02:00
|
|
|
err = helper.ProcessMetaFiles(metadataFiles, "./cmd", stepHelperData)
|
2020-02-18 16:19:50 +02:00
|
|
|
assert.NoError(t, err)
|
|
|
|
}
|