summaryrefslogtreecommitdiff
path: root/internal/store/labels_test.go
diff options
context:
space:
mode:
authorPeter Stone <thepeterstone@gmail.com>2026-07-16 06:27:59 +0000
committerPeter Stone <thepeterstone@gmail.com>2026-07-16 06:27:59 +0000
commit73c3440c579e645ada20f761bbc3eb1c43927e7f (patch)
tree1940b29f8036178ed585c8d1be297877296275bf /internal/store/labels_test.go
parentec45580c839cb94135c6c11c4aecaea255c8f2b7 (diff)
Add budget-tracked toggles for projects/labels; fix SetLabelColor wiping the flag
Diffstat (limited to 'internal/store/labels_test.go')
-rw-r--r--internal/store/labels_test.go60
1 files changed, 60 insertions, 0 deletions
diff --git a/internal/store/labels_test.go b/internal/store/labels_test.go
index 4e97084..79034c8 100644
--- a/internal/store/labels_test.go
+++ b/internal/store/labels_test.go
@@ -82,3 +82,63 @@ func TestSetLabelColor_SameName_Overwrites(t *testing.T) {
t.Fatalf("colors = %+v, want a single entry with the overwritten color", colors)
}
}
+
+func TestSetLabelBudgetTracked_TogglesFlag(t *testing.T) {
+ s := newNativeTasksTestStore(t)
+
+ if err := s.SetLabelBudgetTracked("errands", true); err != nil {
+ t.Fatalf("SetLabelBudgetTracked: %v", err)
+ }
+ names, err := s.GetBudgetTrackedLabelNames()
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !names["errands"] {
+ t.Error("expected 'errands' to be tracked")
+ }
+}
+
+func TestSetLabelColor_PreservesExistingBudgetTracked(t *testing.T) {
+ s := newNativeTasksTestStore(t)
+
+ if err := s.SetLabelBudgetTracked("errands", true); err != nil {
+ t.Fatal(err)
+ }
+ if err := s.SetLabelColor("errands", "#00ff00"); err != nil {
+ t.Fatalf("SetLabelColor: %v", err)
+ }
+
+ names, err := s.GetBudgetTrackedLabelNames()
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !names["errands"] {
+ t.Error("expected budget_tracked to survive a later SetLabelColor call")
+ }
+ colors, err := s.GetLabelColors()
+ if err != nil {
+ t.Fatal(err)
+ }
+ if len(colors) != 1 || colors[0].Color != "#00ff00" {
+ t.Errorf("colors = %+v, want one entry with color #00ff00", colors)
+ }
+}
+
+func TestSetLabelBudgetTracked_PreservesExistingColor(t *testing.T) {
+ s := newNativeTasksTestStore(t)
+
+ if err := s.SetLabelColor("errands", "#00ff00"); err != nil {
+ t.Fatal(err)
+ }
+ if err := s.SetLabelBudgetTracked("errands", true); err != nil {
+ t.Fatal(err)
+ }
+
+ colors, err := s.GetLabelColors()
+ if err != nil {
+ t.Fatal(err)
+ }
+ if len(colors) != 1 || colors[0].Color != "#00ff00" {
+ t.Errorf("colors = %+v, want color to survive SetLabelBudgetTracked", colors)
+ }
+}