MCPcopy Create free account
hub / github.com/basecamp/hey-cli / TestParseAddresses

Function TestParseAddresses

internal/cmd/compose_test.go:7–60  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

5 "strings"
6 "testing"
7
8 "github.com/basecamp/hey-cli/internal/apierr"
9)
10
11func TestParseAddresses(t *testing.T) {
12 tests := []struct {
13 name string
14 input string
15 want []string
16 }{
17 {
18 name: "empty string",
19 input: "",
20 want: nil,
21 },
22 {
23 name: "single address",
24 input: "alice@example.com",
25 want: []string{"alice@example.com"},
26 },
27 {
28 name: "multiple addresses",
29 input: "alice@example.com,bob@example.com",
30 want: []string{"alice@example.com", "bob@example.com"},
31 },
32 {
33 name: "addresses with whitespace",
34 input: " alice@example.com , bob@example.com , carol@example.org ",
35 want: []string{"alice@example.com", "bob@example.com", "carol@example.org"},
36 },
37 {
38 name: "trailing comma",
39 input: "alice@example.com,",
40 want: []string{"alice@example.com"},
41 },
42 {
43 name: "empty entries between commas",
44 input: "alice@example.com,,bob@example.com",
45 want: []string{"alice@example.com", "bob@example.com"},
46 },
47 }
48
49 for _, tt := range tests {
50 t.Run(tt.name, func(t *testing.T) {
51 got := parseAddresses(tt.input)
52 if len(got) != len(tt.want) {
53 t.Fatalf("parseAddresses(%q) = %v (len %d), want %v (len %d)",
54 tt.input, got, len(got), tt.want, len(tt.want))
55 }
56 for i := range got {
57 if got[i] != tt.want[i] {
58 t.Errorf("parseAddresses(%q)[%d] = %q, want %q",
59 tt.input, i, got[i], tt.want[i])
60 }
61 }
62 })
63 }

Callers

nothing calls this directly

Calls 1

parseAddressesFunction · 0.85

Tested by

no test coverage detected