(t *testing.T)
| 118 | } |
| 119 | |
| 120 | func 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 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…