MCPcopy Create free account
hub / github.com/golang/appengine / TestParseRequestHeaders

Function TestParseRequestHeaders

taskqueue/taskqueue_test.go:120–173  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

118}
119
120func TestParseRequestHeaders(t *testing.T) {
121 tests := []struct {
122 Header http.Header
123 Want RequestHeaders
124 }{
125 {
126 Header: map[string][]string{
127 "X-Appengine-Queuename": []string{"foo"},
128 "X-Appengine-Taskname": []string{"bar"},
129 "X-Appengine-Taskretrycount": []string{"4294967297"}, // 2^32 + 1
130 "X-Appengine-Taskexecutioncount": []string{"4294967298"}, // 2^32 + 2
131 "X-Appengine-Tasketa": []string{"1500000000"},
132 "X-Appengine-Taskpreviousresponse": []string{"404"},
133 "X-Appengine-Taskretryreason": []string{"baz"},
134 "X-Appengine-Failfast": []string{"yes"},
135 },
136 Want: RequestHeaders{
137 QueueName: "foo",
138 TaskName: "bar",
139 TaskRetryCount: 4294967297,
140 TaskExecutionCount: 4294967298,
141 TaskETA: time.Date(2017, time.July, 14, 2, 40, 0, 0, time.UTC),
142 TaskPreviousResponse: 404,
143 TaskRetryReason: "baz",
144 FailFast: true,
145 },
146 },
147 {
148 Header: map[string][]string{},
149 Want: RequestHeaders{
150 QueueName: "",
151 TaskName: "",
152 TaskRetryCount: 0,
153 TaskExecutionCount: 0,
154 TaskETA: time.Time{},
155 TaskPreviousResponse: 0,
156 TaskRetryReason: "",
157 FailFast: false,
158 },
159 },
160 }
161
162 for idx, test := range tests {
163 got := *ParseRequestHeaders(test.Header)
164 if got.TaskETA.UnixNano() != test.Want.TaskETA.UnixNano() {
165 t.Errorf("%d. ParseRequestHeaders got TaskETA %v, wanted %v", idx, got.TaskETA, test.Want.TaskETA)
166 }
167 got.TaskETA = time.Time{}
168 test.Want.TaskETA = time.Time{}
169 if !reflect.DeepEqual(got, test.Want) {
170 t.Errorf("%d. ParseRequestHeaders got %v, wanted %v", idx, got, test.Want)
171 }
172 }
173}

Callers

nothing calls this directly

Calls 1

ParseRequestHeadersFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…