mirror of https://github.com/databricks/cli.git
Add unit test that raw strings are printed as is (#599)
## Changes Add unit test that raw strings are printed as is. This method is useful to print text that would otherwise be interpreted a go text template.
This commit is contained in:
parent
47640b8b94
commit
34f196bb4e
|
@ -2,12 +2,28 @@ package template
|
|||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestTemplatePrintStringWithoutProcessing(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
tmpDir := t.TempDir()
|
||||
|
||||
r, err := newRenderer(ctx, nil, "./testdata/print-without-processing/template", "./testdata/print-without-processing/library", tmpDir)
|
||||
require.NoError(t, err)
|
||||
|
||||
err = r.walk()
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Len(t, r.files, 1)
|
||||
cleanContent := strings.Trim(string(r.files[0].content), "\n\r")
|
||||
assert.Equal(t, `{{ fail "abc" }}`, cleanContent)
|
||||
}
|
||||
|
||||
func TestTemplateRegexpCompileFunction(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
tmpDir := t.TempDir()
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
{{`{{ fail "abc" }}`}}
|
Loading…
Reference in New Issue