forked from gobuffalo/plush
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtime_test.go
More file actions
35 lines (27 loc) · 674 Bytes
/
Copy pathtime_test.go
File metadata and controls
35 lines (27 loc) · 674 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package plush_test
import (
"testing"
"time"
"github.com/gobuffalo/plush/v5"
"github.com/stretchr/testify/require"
)
func Test_Default_Time_Format(t *testing.T) {
r := require.New(t)
shortForm := "2006-Jan-02"
tm, err := time.Parse(shortForm, "2013-Feb-03")
r.NoError(err)
ctx := plush.NewContext()
ctx.Set("tm", tm)
input := `<%= tm %>`
s, err := plush.Render(input, ctx)
r.NoError(err)
r.Equal("February 03, 2013 00:00:00 +0000", s)
ctx.Set("TIME_FORMAT", "2006-02-Jan")
s, err = plush.Render(input, ctx)
r.NoError(err)
r.Equal("2013-03-Feb", s)
ctx.Set("tm", &tm)
s, err = plush.Render(input, ctx)
r.NoError(err)
r.Equal("2013-03-Feb", s)
}