(t *testing.T)
| 195 | _, consumed := v.Update(currentPostingsLoaded(v, testPostings())) |
| 196 | if !consumed { |
| 197 | t.Error("postingsLoadedMsg should be consumed") |
| 198 | } |
| 199 | if v.requests.loading { |
| 200 | t.Error("loading should be false after postings loaded") |
| 201 | } |
| 202 | if len(v.postingList.postings) != 2 { |
| 203 | t.Errorf("expected 2 postings, got %d", len(v.postingList.postings)) |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | func TestMailViewIgnoresPostingLoadFromEarlierBoxVisit(t *testing.T) { |
| 208 | v := mailWithPostings() |
| 209 | |
| 210 | v.SubnavRight() |
| 211 | stale := currentPostingsLoaded(v, []mail.Posting{{ID: 200, Summary: "The Feed message"}}) |
| 212 | v.SubnavLeft() |
| 213 | current := currentPostingsLoaded(v, []mail.Posting{{ID: 300, Summary: "Current Imbox message"}}) |
| 214 | v.Update(current) |
| 215 | v.Update(stale) |
| 216 | |
| 217 | if len(v.postingList.postings) != 1 || v.postingList.postings[0].ID != 300 { |
| 218 | t.Errorf("an earlier box visit overwrote the current postings: %v", v.postingList.postings) |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | func TestMailViewReportsCurrentPostingLoadFailure(t *testing.T) { |
| 223 | v, _ := mailWithTestServer(t, http.StatusBadRequest) |
| 224 | |
| 225 | failed, ok := runCmd(v.SubnavRight()).(postingsLoadedMsg) |
| 226 | if !ok || failed.err == nil { |
| 227 | t.Fatalf("posting load returned %#v, want an error", failed) |
| 228 | } |
| 229 | cmd, consumed := v.Update(failed) |
| 230 |
nothing calls this directly
no test coverage detected