@@ -22,7 +22,7 @@ func TestTime_ImplementsUnmarshaler(t *testing.T) {
2222}
2323
2424func TestTime_ImplementsGraphQLType (t * testing.T ) {
25- gt := new ( Time )
25+ gt := & Time {}
2626
2727 if gt .ImplementsGraphQLType ("foobar" ) {
2828 t .Error ("Type *Time must not claim to implement GraphQL type 'foobar'" )
@@ -36,7 +36,7 @@ func TestTime_ImplementsGraphQLType(t *testing.T) {
3636func TestTime_MarshalJSON (t * testing.T ) {
3737 var err error
3838 var b1 , b2 []byte
39- ref := time .Date (2021 , time .April , 20 , 12 , 3 , 23 , 0 , time .UTC )
39+ ref := time .Date (2021 , time .April , 20 , 12 , 3 , 23 , 551476231 , time .UTC )
4040
4141 if b1 , err = json .Marshal (ref ); err != nil {
4242 t .Error (err )
@@ -57,8 +57,8 @@ func TestTime_UnmarshalGraphQL(t *testing.T) {
5757 type args struct {
5858 input interface {}
5959 }
60-
61- ref := time .Date ( 2021 , time . April , 20 , 12 , 3 , 23 , 0 , time . UTC )
60+ ref := time . Date ( 2021 , time . April , 20 , 12 , 3 , 23 , 551476231 , time . UTC )
61+ refZeroNano := time .Unix ( ref . Unix (), 0 )
6262
6363 t .Run ("invalid" , func (t * testing.T ) {
6464 tests := []struct {
@@ -111,46 +111,52 @@ func TestTime_UnmarshalGraphQL(t *testing.T) {
111111 args : args {
112112 input : ref .Format (time .RFC3339 ),
113113 },
114- wantEq : ref ,
114+ wantEq : refZeroNano ,
115115 },
116116 {
117117 name : "bytes" ,
118118 args : args {
119119 input : []byte (ref .Format (time .RFC3339 )),
120120 },
121- wantEq : ref ,
121+ wantEq : refZeroNano ,
122122 },
123123 {
124124 name : "int32" ,
125125 args : args {
126126 input : int32 (ref .Unix ()),
127127 },
128- wantEq : ref ,
128+ wantEq : refZeroNano ,
129129 },
130130 {
131131 name : "int64" ,
132132 args : args {
133133 input : ref .Unix (),
134134 },
135+ wantEq : refZeroNano ,
136+ },
137+ {
138+ name : "int64-nano" ,
139+ args : args {
140+ input : ref .UnixNano (),
141+ },
135142 wantEq : ref ,
136143 },
137144 {
138145 name : "float64" ,
139146 args : args {
140147 input : float64 (ref .Unix ()),
141148 },
142- wantEq : ref ,
149+ wantEq : refZeroNano ,
143150 },
144151 }
145152
146153 for _ , tt := range tests {
147154 t .Run (tt .name , func (t * testing.T ) {
148- gt := new ( Time )
155+ gt := & Time {}
149156 if err := gt .UnmarshalGraphQL (tt .args .input ); err != nil {
150157 t .Errorf ("UnmarshalGraphQL() error = %v" , err )
151158 return
152159 }
153-
154160 if ! gt .Equal (tt .wantEq ) {
155161 t .Errorf ("UnmarshalGraphQL() got = %v, want = %v" , gt , tt .wantEq )
156162 }
0 commit comments