@@ -13,7 +13,7 @@ import (
1313 "time"
1414
1515 cloudevents "github.com/cloudevents/sdk-go/v2"
16- "github.com/cloudevents/sdk-go/v2/types"
16+ // "github.com/cloudevents/sdk-go/v2/types"
1717)
1818
1919func TestSenderReceiver_binary_v1 (t * testing.T ) {
@@ -100,8 +100,9 @@ func TestSenderReceiver_binary_v1(t *testing.T) {
100100}
101101
102102func TestSenderReceiver_structured_v1 (t * testing.T ) {
103+ // TODO: Format that to RFC3339.
103104 now := time .Now ()
104-
105+ // TODO: Use now.Truncate or another similar function like .Round to remove the milliseconds.
105106 testCases := DirectTapTestCases {
106107 "Structured v1.0" : {
107108 now : now ,
@@ -118,7 +119,7 @@ func TestSenderReceiver_structured_v1(t *testing.T) {
118119 Context : cloudevents.EventContextV1 {
119120 ID : "ABC-123" ,
120121 Type : "unit.test.client.sent" ,
121- Time : & cloudevents.Timestamp {Time : now },
122+ Time : & cloudevents.Timestamp {Time : now . Truncate ( time . Second ) },
122123 Source : * cloudevents .ParseURIRef ("/unit/test/client" ),
123124 Subject : strptr ("resource" ),
124125 DataContentType : cloudevents .StringOfApplicationJSON (),
@@ -131,7 +132,7 @@ func TestSenderReceiver_structured_v1(t *testing.T) {
131132 Header : map [string ][]string {
132133 "content-type" : {"application/cloudevents+json" },
133134 },
134- Body : fmt .Sprintf (`{"data":{"hello":"unittest"},"id":"ABC-123","source":"/unit/test/client","specversion":"1.0","subject":"resource","time":%q,"type":"unit.test.client.sent"}` , types . FormatTime ( now .UTC () )),
135+ Body : fmt .Sprintf (`{"data":{"hello":"unittest"},"id":"ABC-123","source":"/unit/test/client","specversion":"1.0","subject":"resource","time":%q,"type":"unit.test.client.sent"}` , now .Truncate ( time . Second ). Format ( time . RFC3339 )),
135136 ContentLength : 182 ,
136137 },
137138 },
@@ -164,7 +165,7 @@ func TestSenderReceiver_data_base64_v1(t *testing.T) {
164165 Context : cloudevents.EventContextV1 {
165166 ID : "ABC-123" ,
166167 Type : "unit.test.client.sent" ,
167- Time : & cloudevents.Timestamp {Time : now },
168+ Time : & cloudevents.Timestamp {Time : now . Truncate ( time . Second ) },
168169 Source : * cloudevents .ParseURIRef ("/unit/test/client" ),
169170 Subject : strptr ("resource" ),
170171 DataContentType : cloudevents .StringOfTextPlain (),
@@ -177,7 +178,7 @@ func TestSenderReceiver_data_base64_v1(t *testing.T) {
177178 Header : map [string ][]string {
178179 "content-type" : {"application/cloudevents+json" },
179180 },
180- Body : fmt .Sprintf (`{"data_base64":"aGVsbG86IHVuaXR0ZXN0","id":"ABC-123","source":"/unit/test/client","specversion":"1.0","subject":"resource","time":%q,"type":"unit.test.client.sent"}` , now .UTC ( ).Format (time .RFC3339Nano ) ),
181+ Body : fmt .Sprintf (`{"data_base64":"aGVsbG86IHVuaXR0ZXN0","id":"ABC-123","source":"/unit/test/client","specversion":"1.0","subject":"resource","time":%q,"type":"unit.test.client.sent"}` ,now .Truncate ( time . Second ).Format (time .RFC3339 ) ),
181182 ContentLength : 191 ,
182183 },
183184 },
0 commit comments