Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions go/pkg/hey/entries.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package hey
import (
"context"
"fmt"
"strings"
"time"

"github.com/basecamp/hey-sdk/go/pkg/generated"
Expand Down Expand Up @@ -73,13 +74,13 @@ func (s *EntriesService) CreateReply(ctx context.Context, entryID int64, content
}
addressed := map[string]any{}
if len(to) > 0 {
addressed["directly"] = to
addressed["directly"] = strings.Join(to, ",")
}
if len(cc) > 0 {
addressed["copied"] = cc
addressed["copied"] = strings.Join(cc, ",")
}
if len(bcc) > 0 {
addressed["blindcopied"] = bcc
addressed["blindcopied"] = strings.Join(bcc, ",")
}
if len(addressed) > 0 {
body["entry"] = map[string]any{
Expand Down
7 changes: 4 additions & 3 deletions go/pkg/hey/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package hey
import (
"context"
"fmt"
"strings"
"time"

"github.com/basecamp/hey-sdk/go/pkg/generated"
Expand Down Expand Up @@ -69,13 +70,13 @@ func (s *MessagesService) Create(ctx context.Context, subject, content string, t

addressed := map[string]any{}
if len(to) > 0 {
addressed["directly"] = to
addressed["directly"] = strings.Join(to, ",")
}
if len(cc) > 0 {
addressed["copied"] = cc
addressed["copied"] = strings.Join(cc, ",")
}
if len(bcc) > 0 {
addressed["blindcopied"] = bcc
addressed["blindcopied"] = strings.Join(bcc, ",")
}

body := map[string]any{
Expand Down
30 changes: 24 additions & 6 deletions go/pkg/hey/services_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,13 +437,13 @@ func TestMessagesService_Create(t *testing.T) {
if !ok {
t.Fatal("missing addressed in entry")
}
directly, ok := addressed["directly"].([]any)
if !ok || len(directly) != 1 || directly[0] != "test@example.com" {
t.Errorf("expected directly ['test@example.com'], got %v", addressed["directly"])
directly, ok := addressed["directly"].(string)
if !ok || directly != "test@example.com" {
t.Errorf("expected directly 'test@example.com', got %v", addressed["directly"])
}
copied, ok := addressed["copied"].([]any)
if !ok || len(copied) != 1 || copied[0] != "cc@example.com" {
t.Errorf("expected copied ['cc@example.com'], got %v", addressed["copied"])
copied, ok := addressed["copied"].(string)
if !ok || copied != "cc@example.com" {
t.Errorf("expected copied 'cc@example.com', got %v", addressed["copied"])
}
if _, ok := addressed["blindcopied"]; ok {
t.Error("expected no blindcopied key for empty bcc")
Expand Down Expand Up @@ -512,6 +512,24 @@ func TestEntriesService_CreateReply(t *testing.T) {
if msg["content"] != "My reply" {
t.Errorf("expected content 'My reply', got %v", msg["content"])
}
entry, ok := body["entry"].(map[string]any)
if !ok {
t.Fatal("missing entry wrapper")
}
addressed, ok := entry["addressed"].(map[string]any)
if !ok {
t.Fatal("missing addressed in entry")
}
directly, ok := addressed["directly"].(string)
if !ok || directly != "test@example.com" {
t.Errorf("expected directly 'test@example.com', got %v", addressed["directly"])
}
if _, ok := addressed["copied"]; ok {
t.Error("expected no copied key for nil cc")
}
if _, ok := addressed["blindcopied"]; ok {
t.Error("expected no blindcopied key for nil bcc")
}
},
`{"notice":"sent"}`,
)
Expand Down
Loading