diff --git a/ast/ast_test.go b/ast/ast_test.go index 50527b7..9d43053 100644 --- a/ast/ast_test.go +++ b/ast/ast_test.go @@ -1,24 +1,25 @@ -package ast +package ast_test import ( "testing" + "github.com/gobuffalo/plush/v4/ast" "github.com/gobuffalo/plush/v4/token" "github.com/stretchr/testify/require" ) func Test_Program_String(t *testing.T) { r := require.New(t) - program := &Program{ - Statements: []Statement{ - &LetStatement{ - TokenAble: TokenAble{token.Token{Type: token.LET, Literal: "let"}}, - Name: &Identifier{ - TokenAble: TokenAble{token.Token{Type: token.IDENT, Literal: "myVar"}}, + program := &ast.Program{ + Statements: []ast.Statement{ + &ast.LetStatement{ + TokenAble: ast.TokenAble{token.Token{Type: token.LET, Literal: "let"}}, + Name: &ast.Identifier{ + TokenAble: ast.TokenAble{token.Token{Type: token.IDENT, Literal: "myVar"}}, Value: "myVar", }, - Value: &Identifier{ - TokenAble: TokenAble{token.Token{Type: token.IDENT, Literal: "anotherVar"}}, + Value: &ast.Identifier{ + TokenAble: ast.TokenAble{token.Token{Type: token.IDENT, Literal: "anotherVar"}}, Value: "anotherVar", }, }, diff --git a/comments_test.go b/comments_test.go index 6981a9d..07d9fff 100644 --- a/comments_test.go +++ b/comments_test.go @@ -1,8 +1,9 @@ -package plush +package plush_test import ( "testing" + "github.com/gobuffalo/plush/v4" "github.com/stretchr/testify/require" ) @@ -20,7 +21,7 @@ func Test_Comment(t *testing.T) { } for _, test := range input { - s, err := Render(test, NewContext()) + s, err := plush.Render(test, plush.NewContext()) r.NoError(err) r.Contains(s, "Hi") r.NotContains(s, "this is a comment") @@ -42,7 +43,7 @@ func Test_BlockComment(t *testing.T) { } for _, test := range input { - s, err := Render(test, NewContext()) + s, err := plush.Render(test, plush.NewContext()) r.NoError(err) r.Contains(s, "Hi") r.NotContains(s, []string{"this is", "a block comment"}) diff --git a/context_test.go b/context_test.go index fedb37f..3d4644e 100644 --- a/context_test.go +++ b/context_test.go @@ -1,4 +1,4 @@ -package plush +package plush_test import ( "html/template" @@ -6,12 +6,13 @@ import ( "golang.org/x/sync/errgroup" + "github.com/gobuffalo/plush/v4" "github.com/stretchr/testify/require" ) func Test_Context_Set(t *testing.T) { r := require.New(t) - c := NewContext() + c := plush.NewContext() r.Nil(c.Value("foo")) c.Set("foo", "bar") r.NotNil(c.Value("foo")) @@ -19,7 +20,7 @@ func Test_Context_Set(t *testing.T) { func Test_Context_Set_Concurrency(t *testing.T) { r := require.New(t) - c := NewContext() + c := plush.NewContext() wg := errgroup.Group{} f := func() error { @@ -35,7 +36,7 @@ func Test_Context_Set_Concurrency(t *testing.T) { func Test_Context_Get(t *testing.T) { r := require.New(t) - c := NewContext() + c := plush.NewContext() r.Nil(c.Value("foo")) c.Set("foo", "bar") r.Equal("bar", c.Value("foo")) @@ -44,7 +45,7 @@ func Test_Context_Get(t *testing.T) { func Test_NewSubContext_Set(t *testing.T) { r := require.New(t) - c := NewContext() + c := plush.NewContext() r.Nil(c.Value("foo")) sc := c.New() @@ -58,7 +59,7 @@ func Test_NewSubContext_Set(t *testing.T) { func Test_NewSubContext_Get(t *testing.T) { r := require.New(t) - c := NewContext() + c := plush.NewContext() c.Set("foo", "bar") sc := c.New() @@ -67,7 +68,7 @@ func Test_NewSubContext_Get(t *testing.T) { func Test_Context_Override_Helper(t *testing.T) { r := require.New(t) - c := NewContext() + c := plush.NewContext() c.Set("debug", func(i interface{}) template.HTML { return template.HTML("DEBUG") }) diff --git a/error_test.go b/error_test.go index 9736f7c..ce06ee8 100644 --- a/error_test.go +++ b/error_test.go @@ -1,4 +1,4 @@ -package plush +package plush_test import ( "database/sql" @@ -6,17 +6,18 @@ import ( "errors" "testing" + "github.com/gobuffalo/plush/v4" "github.com/stretchr/testify/require" ) func TestErrorType(t *testing.T) { r := require.New(t) - ctx := NewContext() + ctx := plush.NewContext() ctx.Set("sqlError", func() error { return sql.ErrNoRows }) - _, err := Render(`<%= sqlError() %>`, ctx) + _, err := plush.Render(`<%= sqlError() %>`, ctx) r.True(errors.Is(err, sql.ErrNoRows)) } diff --git a/escape_test.go b/escape_test.go index d92d1dc..67926ef 100644 --- a/escape_test.go +++ b/escape_test.go @@ -1,9 +1,10 @@ -package plush +package plush_test import ( "html/template" "testing" + "github.com/gobuffalo/plush/v4" "github.com/stretchr/testify/require" ) @@ -11,7 +12,7 @@ func Test_Render_EscapedString(t *testing.T) { r := require.New(t) input := `
<%= "" %>
` - s, err := Render(input, NewContext()) + s, err := plush.Render(input, plush.NewContext()) r.NoError(err) r.Equal("<script>alert('pwned')</script>
", s) } @@ -20,7 +21,7 @@ func Test_Render_HTML_Escape(t *testing.T) { r := require.New(t) input := `<%= escapedHTML() %>|<%= unescapedHTML() %>|<%= raw("unsafe") %>` - s, err := Render(input, NewContextWith(map[string]interface{}{ + s, err := plush.Render(input, plush.NewContextWith(map[string]interface{}{ "escapedHTML": func() string { return "unsafe" }, @@ -36,7 +37,7 @@ func Test_Escaping_EscapeExpression(t *testing.T) { r := require.New(t) input := `C:\\<%= "temp" %>` - s, err := Render(input, NewContext()) + s, err := plush.Render(input, plush.NewContext()) r.NoError(err) r.Equal(`C:\temp`, s) } diff --git a/example_test.go b/example_test.go index cf4714e..a6a9f87 100644 --- a/example_test.go +++ b/example_test.go @@ -1,9 +1,11 @@ -package plush +package plush_test import ( "fmt" "html/template" "log" + + "github.com/gobuffalo/plush/v4" ) // ExampleRender using `if`, `for`, `else`, functions, etc... @@ -20,10 +22,10 @@ func ExampleRender() { <% } %>