Skip to content

Commit d467dd4

Browse files
test(gmail): add regression coverage for cc output in gmail get metadata
1 parent 4ac0383 commit d467dd4

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

internal/cmd/execute_gmail_get_test.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,12 @@ func TestExecute_GmailGet_Metadata_Text(t *testing.T) {
256256
http.Error(w, "bad format", http.StatusBadRequest)
257257
return
258258
}
259+
gotHeaders := r.URL.Query()["metadataHeaders"]
260+
if len(gotHeaders) != 4 || !containsAll(gotHeaders, []string{"From", "Subject", "Cc", "List-Unsubscribe"}) {
261+
t.Errorf("metadataHeaders=%#v", gotHeaders)
262+
http.Error(w, "bad metadataHeaders", http.StatusBadRequest)
263+
return
264+
}
259265
w.Header().Set("Content-Type", "application/json")
260266
_ = json.NewEncoder(w).Encode(map[string]any{
261267
"id": "m1",
@@ -264,6 +270,7 @@ func TestExecute_GmailGet_Metadata_Text(t *testing.T) {
264270
"payload": map[string]any{
265271
"headers": []map[string]any{
266272
{"name": "From", "value": "Me <me@example.com>"},
273+
{"name": "CC", "value": "cc@example.com"},
267274
{"name": "Subject", "value": "Hello"},
268275
},
269276
},
@@ -287,13 +294,13 @@ func TestExecute_GmailGet_Metadata_Text(t *testing.T) {
287294
"--account", "a@b.com",
288295
"gmail", "get", "m1",
289296
"--format", "metadata",
290-
"--headers", "From,Subject",
297+
"--headers", "From,Subject,Cc",
291298
}); err != nil {
292299
t.Fatalf("Execute: %v", err)
293300
}
294301
})
295302
})
296-
if !strings.Contains(out, "id\tm1") || !strings.Contains(out, "subject\tHello") {
303+
if !strings.Contains(out, "id\tm1") || !strings.Contains(out, "cc\tcc@example.com") || !strings.Contains(out, "subject\tHello") {
297304
t.Fatalf("unexpected out=%q", out)
298305
}
299306
}

0 commit comments

Comments
 (0)