Skip to content
Merged
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
5 changes: 5 additions & 0 deletions cmd/entire/cli/api/trail_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@ import (
)

// TrailListResponse is the response from GET /api/v1/trails/:org/:repo.
// The endpoint paginates: Trails holds one page (server max 200 rows) and
// Total is the full match count for the requested filters.
type TrailListResponse struct {
Trails []TrailResource `json:"trails"`
Total int `json:"total"`
Limit int `json:"limit"`
Offset int `json:"offset"`
RepoFullName string `json:"repo_full_name"`
DefaultBranch string `json:"default_branch"`
UpdatedAt time.Time `json:"updated_at"`
Expand Down
12 changes: 6 additions & 6 deletions cmd/entire/cli/trail/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ func TestStore_Update(t *testing.T) {
// Update
if err := store.Update(context.Background(), id, func(m *Metadata) {
m.Title = "Updated"
m.Status = StatusInProgress
m.Status = StatusOpen
m.Labels = []string{"urgent"}
}); err != nil {
t.Fatalf("Update() error = %v", err)
Expand All @@ -270,8 +270,8 @@ func TestStore_Update(t *testing.T) {
if updated.Title != "Updated" {
t.Errorf("Read() title = %q, want %q", updated.Title, "Updated")
}
if updated.Status != StatusInProgress {
t.Errorf("Read() status = %q, want %q", updated.Status, StatusInProgress)
if updated.Status != StatusOpen {
t.Errorf("Read() status = %q, want %q", updated.Status, StatusOpen)
}
if len(updated.Labels) != 1 || updated.Labels[0] != "urgent" {
t.Errorf("Read() labels = %v, want [urgent]", updated.Labels)
Expand Down Expand Up @@ -387,7 +387,7 @@ func TestStore_AddCheckpointPreservesOtherFields(t *testing.T) {
Base: "main",
Title: "Preservation test",
Body: "Verify AddCheckpoint doesn't corrupt other fields",
Status: StatusInProgress,
Status: StatusOpen,
Author: &Author{ID: "1", Login: strPtr("tester")},
Assignees: []string{"alice"},
Labels: []string{"important"},
Expand Down Expand Up @@ -427,8 +427,8 @@ func TestStore_AddCheckpointPreservesOtherFields(t *testing.T) {
if gotMeta.Body != "Verify AddCheckpoint doesn't corrupt other fields" {
t.Errorf("metadata body changed: got %q", gotMeta.Body)
}
if gotMeta.Status != StatusInProgress {
t.Errorf("metadata status changed: got %q, want %q", gotMeta.Status, StatusInProgress)
if gotMeta.Status != StatusOpen {
t.Errorf("metadata status changed: got %q, want %q", gotMeta.Status, StatusOpen)
}
if len(gotMeta.Assignees) != 1 || gotMeta.Assignees[0] != "alice" {
t.Errorf("metadata assignees changed: got %v", gotMeta.Assignees)
Expand Down
15 changes: 7 additions & 8 deletions cmd/entire/cli/trail/trail.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,22 +73,21 @@ func (id ID) ShardParts() (shard, suffix string) {
// Status represents the lifecycle status of a trail.
type Status string

// The status set mirrors the server's repo_trails check constraint
// ('draft', 'open', 'merged', 'closed'). The former in_progress and
// in_review statuses were folded into open server-side.
const (
StatusDraft Status = "draft"
StatusOpen Status = "open"
StatusInProgress Status = "in_progress"
StatusInReview Status = "in_review"
StatusMerged Status = "merged"
StatusClosed Status = "closed"
StatusDraft Status = "draft"
StatusOpen Status = "open"
StatusMerged Status = "merged"
StatusClosed Status = "closed"
)

// ValidStatuses returns all valid trail statuses in lifecycle order.
func ValidStatuses() []Status {
return []Status{
StatusDraft,
StatusOpen,
StatusInProgress,
StatusInReview,
StatusMerged,
StatusClosed,
}
Expand Down
11 changes: 6 additions & 5 deletions cmd/entire/cli/trail/trail_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,11 @@ func TestStatus_IsValid(t *testing.T) {
}{
{StatusDraft, true},
{StatusOpen, true},
{StatusInProgress, true},
{StatusInReview, true},
{StatusMerged, true},
{StatusClosed, true},
// Retired server-side (folded into open); no longer accepted.
{"in_progress", false},
{"in_review", false},
{"invalid", false},
{"", false},
}
Expand All @@ -128,11 +129,11 @@ func TestValidStatuses(t *testing.T) {
t.Parallel()

statuses := ValidStatuses()
if len(statuses) != 6 {
t.Errorf("expected 6 statuses, got %d", len(statuses))
if len(statuses) != 4 {
t.Errorf("expected 4 statuses, got %d", len(statuses))
}
// Verify lifecycle order
expected := []Status{StatusDraft, StatusOpen, StatusInProgress, StatusInReview, StatusMerged, StatusClosed}
expected := []Status{StatusDraft, StatusOpen, StatusMerged, StatusClosed}
for i, s := range expected {
if statuses[i] != s {
t.Errorf("status[%d] = %q, want %q", i, statuses[i], s)
Expand Down
Loading
Loading