| 46 | } |
| 47 | |
| 48 | func TestUpdateMessageLabels_AddRemove(t *testing.T) { |
| 49 | srv := httptest.NewServer(New(labelDeps())) |
| 50 | t.Cleanup(srv.Close) |
| 51 | code, body := sendJSON(t, "PATCH", srv.URL+"/v1/agents/support%40acme.com/messages/msg_a", "good", map[string]any{ |
| 52 | "add_labels": []string{"urgent", "vip"}, |
| 53 | }) |
| 54 | if code != 200 { |
| 55 | t.Fatalf("status %d body %v", code, body) |
| 56 | } |
| 57 | if body["message_id"] != "msg_a" { |
| 58 | t.Fatalf("message_id = %v, want msg_a", body["message_id"]) |
| 59 | } |
| 60 | labels, _ := body["labels"].([]any) |
| 61 | if len(labels) != 2 || labels[0] != "urgent" { |
| 62 | t.Fatalf("labels = %v, want [urgent vip]", body["labels"]) |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | func TestUpdateMessageLabels_CapExceededIs400(t *testing.T) { |
| 67 | srv := httptest.NewServer(New(labelDeps())) |