1
0
Fork 0
mirror of https://github.com/drone/drone-cli.git synced 2024-05-08 00:26:03 +02:00
drone-cli/drone/jsonnet/jsonnet_test.go
Sean Ryan 55e0addb31
Add support for jpath in jsonnet (#224)
* Add support for jpath in jsonnet
Co-authored-by: TP Honey <tp@harness.io>
2022-12-06 12:30:36 +00:00

46 lines
1.1 KiB
Go

package jsonnet
import (
"os"
"path/filepath"
"testing"
"github.com/stretchr/testify/assert"
)
func TestConvert(t *testing.T) {
testcases := []struct {
name string
jsonnetFile, yamlFile string
stringOutput, format, stream bool
extVars []string
jpath []string
}{
{
name: "Stream + Format",
jsonnetFile: "stream_format.jsonnet",
yamlFile: "stream_format.yaml",
format: true, stream: true,
},
{
name: "Jsonnet Path",
jsonnetFile: "stream_format.jsonnet",
yamlFile: "stream_format.yaml",
format: true, stream: true,
jpath: []string{"/path/to/jsonnet/lib"},
},
}
for _, tc := range testcases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
expected, err := os.ReadFile(filepath.Join("./testdata", tc.yamlFile))
assert.NoError(t, err)
result, err := convert(filepath.Join("./testdata", tc.jsonnetFile), tc.stringOutput, tc.format, tc.stream, tc.extVars, tc.jpath)
assert.NoError(t, err)
assert.Equal(t, string(expected), result)
})
}
}