...
1 package graphql
2
3 import (
4 "bytes"
5 "strconv"
6 "testing"
7 "time"
8
9 "github.com/stretchr/testify/require"
10 )
11
12 func TestTime(t *testing.T) {
13 t.Run("symmetry", func(t *testing.T) {
14 initialTime := time.Now()
15 buf := bytes.NewBuffer([]byte{})
16 MarshalTime(initialTime).MarshalGQL(buf)
17
18 str, err := strconv.Unquote(buf.String())
19 require.Nil(t, err)
20 newTime, err := UnmarshalTime(str)
21 require.Nil(t, err)
22
23 require.True(t, initialTime.Equal(newTime), "expected times %v and %v to equal", initialTime, newTime)
24 })
25 }
26
View as plain text