@@ -13,7 +13,7 @@ import (
13
13
"time"
14
14
15
15
cloudevents "github.com/cloudevents/sdk-go/v2"
16
- "github.com/cloudevents/sdk-go/v2/types"
16
+ // "github.com/cloudevents/sdk-go/v2/types"
17
17
)
18
18
19
19
func TestSenderReceiver_binary_v1 (t * testing.T ) {
@@ -100,8 +100,9 @@ func TestSenderReceiver_binary_v1(t *testing.T) {
100
100
}
101
101
102
102
func TestSenderReceiver_structured_v1 (t * testing.T ) {
103
+ // TODO: Format that to RFC3339.
103
104
now := time .Now ()
104
-
105
+ // TODO: Use now.Truncate or another similar function like .Round to remove the milliseconds.
105
106
testCases := DirectTapTestCases {
106
107
"Structured v1.0" : {
107
108
now : now ,
@@ -118,7 +119,7 @@ func TestSenderReceiver_structured_v1(t *testing.T) {
118
119
Context : cloudevents.EventContextV1 {
119
120
ID : "ABC-123" ,
120
121
Type : "unit.test.client.sent" ,
121
- Time : & cloudevents.Timestamp {Time : now },
122
+ Time : & cloudevents.Timestamp {Time : now . Truncate ( time . Second ) },
122
123
Source : * cloudevents .ParseURIRef ("/unit/test/client" ),
123
124
Subject : strptr ("resource" ),
124
125
DataContentType : cloudevents .StringOfApplicationJSON (),
@@ -131,7 +132,7 @@ func TestSenderReceiver_structured_v1(t *testing.T) {
131
132
Header : map [string ][]string {
132
133
"content-type" : {"application/cloudevents+json" },
133
134
},
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 )),
135
136
ContentLength : 182 ,
136
137
},
137
138
},
@@ -164,7 +165,7 @@ func TestSenderReceiver_data_base64_v1(t *testing.T) {
164
165
Context : cloudevents.EventContextV1 {
165
166
ID : "ABC-123" ,
166
167
Type : "unit.test.client.sent" ,
167
- Time : & cloudevents.Timestamp {Time : now },
168
+ Time : & cloudevents.Timestamp {Time : now . Truncate ( time . Second ) },
168
169
Source : * cloudevents .ParseURIRef ("/unit/test/client" ),
169
170
Subject : strptr ("resource" ),
170
171
DataContentType : cloudevents .StringOfTextPlain (),
@@ -177,7 +178,7 @@ func TestSenderReceiver_data_base64_v1(t *testing.T) {
177
178
Header : map [string ][]string {
178
179
"content-type" : {"application/cloudevents+json" },
179
180
},
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 ) ),
181
182
ContentLength : 191 ,
182
183
},
183
184
},
0 commit comments