Skip to content

Commit f125d6e

Browse files
committed
Update to hey-sdk 0.1.1
1 parent 3610f51 commit f125d6e

8 files changed

Lines changed: 23 additions & 45 deletions

File tree

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
charm.land/bubbles/v2 v2.0.0
77
charm.land/bubbletea/v2 v2.0.2
88
charm.land/lipgloss/v2 v2.0.1
9-
github.com/basecamp/hey-sdk/go v0.1.0
9+
github.com/basecamp/hey-sdk/go v0.1.1
1010
github.com/mattn/go-runewidth v0.0.21
1111
github.com/spf13/cobra v1.10.2
1212
github.com/spf13/pflag v1.0.10

go.sum

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ charm.land/bubbletea/v2 v2.0.2 h1:4CRtRnuZOdFDTWSff9r8QFt/9+z6Emubz3aDMnf/dx0=
66
charm.land/bubbletea/v2 v2.0.2/go.mod h1:3LRff2U4WIYXy7MTxfbAQ+AdfM3D8Xuvz2wbsOD9OHQ=
77
charm.land/lipgloss/v2 v2.0.1 h1:6Xzrn49+Py1Um5q/wZG1gWgER2+7dUyZ9XMEufqPSys=
88
charm.land/lipgloss/v2 v2.0.1/go.mod h1:KjPle2Qd3YmvP1KL5OMHiHysGcNwq6u83MUjYkFvEkM=
9+
github.com/RaveNoX/go-jsoncommentstrip v1.0.0/go.mod h1:78ihd09MekBnJnxpICcwzCMzGrKSKYe4AqU6PDYYpjk=
10+
github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7Dml6nw9rQ=
11+
github.com/apapsch/go-jsonmerge/v2 v2.0.0/go.mod h1:lvDnEdqiQrp0O42VQGgmlKpxL1AP2+08jFMw88y4klk=
912
github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4=
1013
github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
1114
github.com/aymanbagabas/go-udiff v0.4.1 h1:OEIrQ8maEeDBXQDoGCbbTTXYJMYRCRO1fnodZ12Gv5o=
1215
github.com/aymanbagabas/go-udiff v0.4.1/go.mod h1:0L9PGwj20lrtmEMeyw4WKJ/TMyDtvAoK9bf2u/mNo3w=
13-
github.com/RaveNoX/go-jsoncommentstrip v1.0.0/go.mod h1:78ihd09MekBnJnxpICcwzCMzGrKSKYe4AqU6PDYYpjk=
14-
github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7Dml6nw9rQ=
15-
github.com/apapsch/go-jsonmerge/v2 v2.0.0/go.mod h1:lvDnEdqiQrp0O42VQGgmlKpxL1AP2+08jFMw88y4klk=
16-
github.com/basecamp/hey-sdk/go v0.1.0 h1:b2VsJGQh9tFMG1OrZpG7zEnipV33y4VeSf20EDPlWUA=
17-
github.com/basecamp/hey-sdk/go v0.1.0/go.mod h1:vHKyozk7SNjDrGqgdYIelXjiwBk6az0KSC+73Wt3dbI=
16+
github.com/basecamp/hey-sdk/go v0.1.1 h1:IACc6wav+HGjHr1cfB0NuiZw3q5tzy/wDFrHgBniP40=
17+
github.com/basecamp/hey-sdk/go v0.1.1/go.mod h1:vHKyozk7SNjDrGqgdYIelXjiwBk6az0KSC+73Wt3dbI=
1818
github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvFv1sNto9p6w=
1919
github.com/charmbracelet/colorprofile v0.4.2 h1:BdSNuMjRbotnxHSfxy+PCSa4xAmz7szw70ktAtWRYrY=
2020
github.com/charmbracelet/colorprofile v0.4.2/go.mod h1:0rTi81QpwDElInthtrQ6Ni7cG0sDtwAd4C4le060fT8=

internal/cmd/journal_test.go

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"bytes"
55
"encoding/json"
66
"fmt"
7-
"io"
87
"net/http"
98
"net/http/httptest"
109
"strings"
@@ -55,18 +54,7 @@ func journalServerWithReadBehavior(t *testing.T, readBehavior string) *httptest.
5554
json.NewEncoder(w).Encode(resp)
5655
}
5756
case r.Method == "PATCH" && strings.Contains(r.URL.Path, "/calendar/days/") && (strings.HasSuffix(r.URL.Path, "/journal_entry") || strings.HasSuffix(r.URL.Path, "/journal_entry.json")):
58-
body, _ := io.ReadAll(r.Body)
59-
var req map[string]any
60-
_ = json.Unmarshal(body, &req)
61-
resp := map[string]any{
62-
"id": 1,
63-
"content": req["body"],
64-
"type": "Calendar::JournalEntry",
65-
"title": "Journal Entry",
66-
"starts_at": "2024-01-15T00:00:00Z",
67-
}
68-
w.Header().Set("Content-Type", "application/json")
69-
json.NewEncoder(w).Encode(resp)
57+
w.WriteHeader(204)
7058
default:
7159
w.WriteHeader(200)
7260
}
@@ -106,12 +94,8 @@ func TestJournalWritePositionalContent(t *testing.T) {
10694
t.Fatalf("execute: %v", err)
10795
}
10896

109-
data, ok := resp.Data.(map[string]any)
110-
if !ok {
111-
t.Fatalf("data type = %T, want map[string]any", resp.Data)
112-
}
113-
if got := data["content"]; got != "Today was great" {
114-
t.Errorf("content = %q, want %q", got, "Today was great")
97+
if !strings.Contains(resp.Summary, "Journal entry") {
98+
t.Errorf("summary = %q, want to contain %q", resp.Summary, "Journal entry")
11599
}
116100
}
117101

@@ -124,12 +108,8 @@ func TestJournalWritePositionalDateAndContent(t *testing.T) {
124108
t.Fatalf("execute: %v", err)
125109
}
126110

127-
data, ok := resp.Data.(map[string]any)
128-
if !ok {
129-
t.Fatalf("data type = %T, want map[string]any", resp.Data)
130-
}
131-
if got := data["content"]; got != "Retrospective" {
132-
t.Errorf("content = %q, want %q", got, "Retrospective")
111+
if !strings.Contains(resp.Summary, "2024-01-15") {
112+
t.Errorf("summary = %q, want to contain date", resp.Summary)
133113
}
134114
}
135115

@@ -142,12 +122,8 @@ func TestJournalWriteShortFlag(t *testing.T) {
142122
t.Fatalf("execute: %v", err)
143123
}
144124

145-
data, ok := resp.Data.(map[string]any)
146-
if !ok {
147-
t.Fatalf("data type = %T, want map[string]any", resp.Data)
148-
}
149-
if got := data["content"]; got != "Content via short flag" {
150-
t.Errorf("content = %q, want %q", got, "Content via short flag")
125+
if !strings.Contains(resp.Summary, "Journal entry") {
126+
t.Errorf("summary = %q, want to contain %q", resp.Summary, "Journal entry")
151127
}
152128
}
153129

internal/cmd/todo_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,14 @@ func todoServer(t *testing.T) *httptest.Server {
2121
body, _ := io.ReadAll(r.Body)
2222
var req map[string]any
2323
_ = json.Unmarshal(body, &req)
24+
todo, _ := req["calendar_todo"].(map[string]any)
25+
title := ""
26+
if todo != nil {
27+
title, _ = todo["title"].(string)
28+
}
2429
resp := map[string]any{
2530
"id": 1,
26-
"title": req["title"],
31+
"title": title,
2732
}
2833
w.Header().Set("Content-Type", "application/json")
2934
json.NewEncoder(w).Encode(resp)

internal/tui/journal_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func TestJournalSetItemsFiltersAndSorts(t *testing.T) {
2323
}
2424

2525
// Should be reverse-chronological
26-
wantIDs := []int{3, 2, 4}
26+
wantIDs := []int64{3, 2, 4}
2727
for i, wantID := range wantIDs {
2828
got := items[i].(journalItem).recording.ID
2929
if got != wantID {

tests/smoke/browser_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,3 @@ func TestCLIJournalVisibleInBrowser(t *testing.T) {
117117
// The content should appear somewhere on the page.
118118
assertContains(t, text, uid)
119119
}
120-

tests/smoke/habit_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ func deleteTestHabit(t *testing.T, habitID int) {
112112
resp.Body.Close()
113113
}
114114

115-
116115
func TestHabitComplete(t *testing.T) {
117116
uid := uniqueID()
118117
name := fmt.Sprintf("Test habit %s", uid)

tests/smoke/helpers_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@ import (
1919

2020
// Shared test state set up once in TestMain.
2121
var (
22-
binaryPath string
23-
baseURL string
24-
configDir string
22+
binaryPath string
23+
baseURL string
24+
configDir string
2525
sessionCookie string
26-
2726
)
2827

2928
// Response mirrors the CLI's JSON envelope.

0 commit comments

Comments
 (0)