MCPcopy Create free account
hub / github.com/driangle/taskmd / TestGroupSnapshots

Function TestGroupSnapshots

apps/cli/internal/cli/snapshot_test.go:163–198  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

161}
162
163func TestGroupSnapshots(t *testing.T) {
164 snapshots := []TaskSnapshot{
165 {ID: "001", Status: "completed", Priority: "high", Effort: "small", Group: "backend"},
166 {ID: "002", Status: "pending", Priority: "medium", Effort: "medium"},
167 {ID: "003", Status: "pending", Priority: "low", Effort: "large", Group: "frontend"},
168 }
169
170 tests := []struct {
171 name string
172 groupBy string
173 wantKey string
174 }{
175 {"by status", "status", "pending"},
176 {"by priority", "priority", "high"},
177 {"by effort", "effort", "small"},
178 {"by group", "group", "backend"},
179 {"unknown field", "unknown", "ungrouped"},
180 }
181
182 for _, tt := range tests {
183 t.Run(tt.name, func(t *testing.T) {
184 groups := groupSnapshots(snapshots, tt.groupBy)
185 if _, ok := groups[tt.wantKey]; !ok {
186 t.Errorf("expected key %q in groups, got keys: %v", tt.wantKey, groupKeys(groups))
187 }
188 })
189 }
190
191 // Empty field → "none"
192 t.Run("empty field becomes none", func(t *testing.T) {
193 groups := groupSnapshots(snapshots, "group")
194 if _, ok := groups["none"]; !ok {
195 t.Errorf("expected 'none' key for empty group field, got keys: %v", groupKeys(groups))
196 }
197 })
198}
199
200func groupKeys(m map[string][]TaskSnapshot) []string {
201 keys := make([]string, 0, len(m))

Callers

nothing calls this directly

Calls 2

groupSnapshotsFunction · 0.85
groupKeysFunction · 0.85

Tested by

no test coverage detected