fizzy-cli 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/docs/API.md +63 -2
  2. package/package.json +2 -1
  3. package/.github/workflows/release.yml +0 -29
  4. package/.github/workflows/tests.yml +0 -24
  5. package/AGENTS.md +0 -33
  6. package/CHANGELOG.md +0 -168
  7. package/Makefile +0 -43
  8. package/bin/fizzy +0 -0
  9. package/cmd/account.go +0 -14
  10. package/cmd/account_list.go +0 -44
  11. package/cmd/account_list_test.go +0 -118
  12. package/cmd/board.go +0 -49
  13. package/cmd/board_create.go +0 -59
  14. package/cmd/board_create_test.go +0 -141
  15. package/cmd/board_delete.go +0 -40
  16. package/cmd/board_delete_test.go +0 -121
  17. package/cmd/board_list.go +0 -44
  18. package/cmd/board_list_test.go +0 -115
  19. package/cmd/board_show.go +0 -40
  20. package/cmd/board_show_test.go +0 -113
  21. package/cmd/board_test.go +0 -92
  22. package/cmd/board_update.go +0 -72
  23. package/cmd/board_update_test.go +0 -233
  24. package/cmd/card.go +0 -24
  25. package/cmd/card_assign.go +0 -55
  26. package/cmd/card_assign_test.go +0 -130
  27. package/cmd/card_close.go +0 -46
  28. package/cmd/card_close_test.go +0 -92
  29. package/cmd/card_create.go +0 -72
  30. package/cmd/card_create_test.go +0 -186
  31. package/cmd/card_delete.go +0 -46
  32. package/cmd/card_delete_test.go +0 -92
  33. package/cmd/card_golden.go +0 -46
  34. package/cmd/card_golden_test.go +0 -92
  35. package/cmd/card_list.go +0 -53
  36. package/cmd/card_list_test.go +0 -148
  37. package/cmd/card_not_now.go +0 -46
  38. package/cmd/card_not_now_test.go +0 -92
  39. package/cmd/card_reopen.go +0 -46
  40. package/cmd/card_reopen_test.go +0 -92
  41. package/cmd/card_show.go +0 -46
  42. package/cmd/card_show_test.go +0 -92
  43. package/cmd/card_tag.go +0 -51
  44. package/cmd/card_tag_test.go +0 -112
  45. package/cmd/card_triage.go +0 -46
  46. package/cmd/card_ungolden.go +0 -46
  47. package/cmd/card_ungolden_test.go +0 -92
  48. package/cmd/card_untriage.go +0 -46
  49. package/cmd/card_untriage_test.go +0 -92
  50. package/cmd/card_unwatch.go +0 -46
  51. package/cmd/card_unwatch_test.go +0 -92
  52. package/cmd/card_update.go +0 -82
  53. package/cmd/card_update_test.go +0 -149
  54. package/cmd/card_watch.go +0 -46
  55. package/cmd/card_watch_test.go +0 -92
  56. package/cmd/column.go +0 -14
  57. package/cmd/column_create.go +0 -79
  58. package/cmd/column_create_test.go +0 -178
  59. package/cmd/column_delete.go +0 -40
  60. package/cmd/column_delete_test.go +0 -121
  61. package/cmd/column_list.go +0 -44
  62. package/cmd/column_list_test.go +0 -138
  63. package/cmd/column_show.go +0 -40
  64. package/cmd/column_show_test.go +0 -111
  65. package/cmd/column_update.go +0 -67
  66. package/cmd/column_update_test.go +0 -198
  67. package/cmd/comment.go +0 -14
  68. package/cmd/comment_create.go +0 -51
  69. package/cmd/comment_create_test.go +0 -129
  70. package/cmd/comment_delete.go +0 -46
  71. package/cmd/comment_delete_test.go +0 -92
  72. package/cmd/comment_list.go +0 -51
  73. package/cmd/comment_list_test.go +0 -132
  74. package/cmd/comment_show.go +0 -46
  75. package/cmd/comment_show_test.go +0 -104
  76. package/cmd/comment_update.go +0 -51
  77. package/cmd/comment_update_test.go +0 -130
  78. package/cmd/login.go +0 -81
  79. package/cmd/login_test.go +0 -98
  80. package/cmd/notification.go +0 -14
  81. package/cmd/notification_list.go +0 -69
  82. package/cmd/notification_list_test.go +0 -288
  83. package/cmd/notification_read.go +0 -51
  84. package/cmd/notification_read_all.go +0 -38
  85. package/cmd/notification_read_all_test.go +0 -75
  86. package/cmd/notification_read_test.go +0 -138
  87. package/cmd/notification_unread.go +0 -44
  88. package/cmd/notification_unread_test.go +0 -99
  89. package/cmd/reaction.go +0 -13
  90. package/cmd/reaction_create.go +0 -46
  91. package/cmd/reaction_create_test.go +0 -113
  92. package/cmd/reaction_delete.go +0 -46
  93. package/cmd/reaction_delete_test.go +0 -92
  94. package/cmd/reaction_list.go +0 -51
  95. package/cmd/reaction_list_test.go +0 -125
  96. package/cmd/root.go +0 -38
  97. package/cmd/step.go +0 -14
  98. package/cmd/step_create.go +0 -53
  99. package/cmd/step_create_test.go +0 -171
  100. package/cmd/step_delete.go +0 -46
  101. package/cmd/step_delete_test.go +0 -92
  102. package/cmd/step_update.go +0 -66
  103. package/cmd/step_update_test.go +0 -190
  104. package/cmd/tag.go +0 -15
  105. package/cmd/tag_list.go +0 -47
  106. package/cmd/tag_list_test.go +0 -109
  107. package/cmd/use.go +0 -85
  108. package/cmd/use_test.go +0 -186
  109. package/go.mod +0 -31
  110. package/go.sum +0 -53
  111. package/internal/api/boards.go +0 -93
  112. package/internal/api/cards.go +0 -288
  113. package/internal/api/client.go +0 -99
  114. package/internal/api/columns.go +0 -113
  115. package/internal/api/comments.go +0 -108
  116. package/internal/api/identity.go +0 -24
  117. package/internal/api/notifications.go +0 -89
  118. package/internal/api/reactions.go +0 -69
  119. package/internal/api/steps.go +0 -101
  120. package/internal/api/tags.go +0 -24
  121. package/internal/api/types.go +0 -190
  122. package/internal/app/app.go +0 -49
  123. package/internal/colors/colors.go +0 -32
  124. package/internal/config/config.go +0 -70
  125. package/internal/testutil/client.go +0 -26
  126. package/internal/ui/account_list.go +0 -14
  127. package/internal/ui/account_selector.go +0 -63
  128. package/internal/ui/board_list.go +0 -14
  129. package/internal/ui/board_show.go +0 -17
  130. package/internal/ui/card_list.go +0 -14
  131. package/internal/ui/card_show.go +0 -23
  132. package/internal/ui/column_list.go +0 -28
  133. package/internal/ui/column_show.go +0 -16
  134. package/internal/ui/comment_list.go +0 -25
  135. package/internal/ui/format.go +0 -27
  136. package/internal/ui/notification_list.go +0 -27
  137. package/internal/ui/reaction_list.go +0 -14
@@ -1,149 +0,0 @@
1
- package cmd
2
-
3
- import (
4
- "context"
5
- "encoding/json"
6
- "net/http"
7
- "net/http/httptest"
8
- "testing"
9
-
10
- "github.com/rogeriopvl/fizzy/internal/api"
11
- "github.com/rogeriopvl/fizzy/internal/app"
12
- "github.com/rogeriopvl/fizzy/internal/testutil"
13
- "github.com/spf13/cobra"
14
- )
15
-
16
- func TestCardUpdateCommand(t *testing.T) {
17
- server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
18
- if r.URL.Path != "/cards/1" {
19
- t.Errorf("expected /cards/1, got %s", r.URL.Path)
20
- }
21
- if r.Method != http.MethodPut {
22
- t.Errorf("expected PUT, got %s", r.Method)
23
- }
24
-
25
- auth := r.Header.Get("Authorization")
26
- if auth != "Bearer test-token" {
27
- t.Errorf("expected Bearer test-token, got %s", auth)
28
- }
29
-
30
- w.Header().Set("Content-Type", "application/json")
31
- response := api.Card{
32
- ID: "card-123",
33
- Number: 1,
34
- Title: "Updated card title",
35
- Status: "published",
36
- Description: "Updated description",
37
- Tags: []string{"updated-tag"},
38
- Golden: false,
39
- CreatedAt: "2025-01-01T00:00:00Z",
40
- LastActiveAt: "2025-01-15T10:30:00Z",
41
- URL: "https://example.com/card/1",
42
- }
43
- json.NewEncoder(w).Encode(response)
44
- }))
45
- defer server.Close()
46
-
47
- client := testutil.NewTestClient(server.URL, "", "", "test-token")
48
- testApp := &app.App{Client: client}
49
-
50
- cmd := cardUpdateCmd
51
- cmd.SetContext(testApp.ToContext(context.Background()))
52
- cmd.ParseFlags([]string{
53
- "--title", "Updated card title",
54
- "--description", "Updated description",
55
- "--status", "published",
56
- "--tag-id", "updated-tag",
57
- })
58
-
59
- if err := handleUpdateCard(cmd, "1"); err != nil {
60
- t.Fatalf("handleUpdateCard failed: %v", err)
61
- }
62
- }
63
-
64
- func TestCardUpdateCommandAPIError(t *testing.T) {
65
- server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
66
- w.WriteHeader(http.StatusNotFound)
67
- w.Write([]byte("Card not found"))
68
- }))
69
- defer server.Close()
70
-
71
- client := testutil.NewTestClient(server.URL, "", "", "test-token")
72
- testApp := &app.App{Client: client}
73
-
74
- cmd := cardUpdateCmd
75
- cmd.SetContext(testApp.ToContext(context.Background()))
76
- cmd.ParseFlags([]string{
77
- "--title", "Updated card",
78
- })
79
-
80
- err := handleUpdateCard(cmd, "999")
81
- if err == nil {
82
- t.Errorf("expected error for API failure")
83
- }
84
- if err.Error() != "updating card: unexpected status code 404: Card not found" {
85
- t.Errorf("expected API error, got %v", err)
86
- }
87
- }
88
-
89
- func TestCardUpdateCommandNoClient(t *testing.T) {
90
- testApp := &app.App{}
91
-
92
- cmd := cardUpdateCmd
93
- cmd.SetContext(testApp.ToContext(context.Background()))
94
- cmd.ParseFlags([]string{
95
- "--title", "Updated card",
96
- })
97
-
98
- err := handleUpdateCard(cmd, "1")
99
- if err == nil {
100
- t.Errorf("expected error when client not available")
101
- }
102
- if err.Error() != "API client not available" {
103
- t.Errorf("expected 'client not available' error, got %v", err)
104
- }
105
- }
106
-
107
- func TestCardUpdateCommandInvalidCardNumber(t *testing.T) {
108
- testApp := &app.App{}
109
-
110
- cmd := cardUpdateCmd
111
- cmd.SetContext(testApp.ToContext(context.Background()))
112
- cmd.ParseFlags([]string{
113
- "--title", "Updated card",
114
- })
115
-
116
- err := handleUpdateCard(cmd, "not-a-number")
117
- if err == nil {
118
- t.Errorf("expected error for invalid card number")
119
- }
120
- if err.Error() != "invalid card number: strconv.Atoi: parsing \"not-a-number\": invalid syntax" {
121
- t.Errorf("expected invalid card number error, got %v", err)
122
- }
123
- }
124
-
125
- func TestCardUpdateCommandNoFlags(t *testing.T) {
126
- client := testutil.NewTestClient("http://localhost", "", "", "test-token")
127
- testApp := &app.App{Client: client}
128
-
129
- // Create a fresh command to avoid flag pollution from other tests
130
- cmd := &cobra.Command{
131
- Use: "update <card_number>",
132
- Args: cobra.ExactArgs(1),
133
- }
134
- cmd.Flags().String("title", "", "Card title")
135
- cmd.Flags().String("description", "", "Card description")
136
- cmd.Flags().String("status", "", "Card status")
137
- cmd.Flags().StringSlice("tag-id", []string{}, "Tag ID")
138
- cmd.Flags().String("last-active-at", "", "Last active timestamp")
139
-
140
- cmd.SetContext(testApp.ToContext(context.Background()))
141
-
142
- err := handleUpdateCard(cmd, "1")
143
- if err == nil {
144
- t.Errorf("expected error when no flags are provided")
145
- }
146
- if err.Error() != "must provide at least one flag to update (--title, --description, --status, --tag-id, or --last-active-at)" {
147
- t.Errorf("expected 'no flags' error, got %v", err)
148
- }
149
- }
package/cmd/card_watch.go DELETED
@@ -1,46 +0,0 @@
1
- package cmd
2
-
3
- import (
4
- "context"
5
- "fmt"
6
- "strconv"
7
-
8
- "github.com/rogeriopvl/fizzy/internal/app"
9
- "github.com/spf13/cobra"
10
- )
11
-
12
- var cardWatchCmd = &cobra.Command{
13
- Use: "watch <card_number>",
14
- Short: "Subscribe to card notifications",
15
- Long: `Subscribe to notifications for an existing card`,
16
- Args: cobra.ExactArgs(1),
17
- Run: func(cmd *cobra.Command, args []string) {
18
- if err := handleWatchCard(cmd, args[0]); err != nil {
19
- fmt.Fprintf(cmd.OutOrStderr(), "Error: %v\n", err)
20
- }
21
- },
22
- }
23
-
24
- func handleWatchCard(cmd *cobra.Command, cardNumber string) error {
25
- cardNum, err := strconv.Atoi(cardNumber)
26
- if err != nil {
27
- return fmt.Errorf("invalid card number: %w", err)
28
- }
29
-
30
- a := app.FromContext(cmd.Context())
31
- if a == nil || a.Client == nil {
32
- return fmt.Errorf("API client not available")
33
- }
34
-
35
- _, err = a.Client.PostCardWatch(context.Background(), cardNum)
36
- if err != nil {
37
- return fmt.Errorf("watching card: %w", err)
38
- }
39
-
40
- fmt.Fprintf(cmd.OutOrStdout(), "✓ Now watching card #%d\n", cardNum)
41
- return nil
42
- }
43
-
44
- func init() {
45
- cardCmd.AddCommand(cardWatchCmd)
46
- }
@@ -1,92 +0,0 @@
1
- package cmd
2
-
3
- import (
4
- "context"
5
- "net/http"
6
- "net/http/httptest"
7
- "testing"
8
-
9
- "github.com/rogeriopvl/fizzy/internal/app"
10
- "github.com/rogeriopvl/fizzy/internal/testutil"
11
- )
12
-
13
- func TestCardWatchCommandSuccess(t *testing.T) {
14
- server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
15
- if r.URL.Path != "/cards/123/watch" {
16
- t.Errorf("expected /cards/123/watch, got %s", r.URL.Path)
17
- }
18
- if r.Method != http.MethodPost {
19
- t.Errorf("expected POST, got %s", r.Method)
20
- }
21
-
22
- auth := r.Header.Get("Authorization")
23
- if auth != "Bearer test-token" {
24
- t.Errorf("expected Bearer test-token, got %s", auth)
25
- }
26
-
27
- w.WriteHeader(http.StatusNoContent)
28
- }))
29
- defer server.Close()
30
-
31
- client := testutil.NewTestClient(server.URL, "", "", "test-token")
32
- testApp := &app.App{Client: client}
33
-
34
- cmd := cardWatchCmd
35
- cmd.SetContext(testApp.ToContext(context.Background()))
36
-
37
- if err := handleWatchCard(cmd, "123"); err != nil {
38
- t.Fatalf("handleWatchCard failed: %v", err)
39
- }
40
- }
41
-
42
- func TestCardWatchCommandInvalidCardNumber(t *testing.T) {
43
- testApp := &app.App{}
44
-
45
- cmd := cardWatchCmd
46
- cmd.SetContext(testApp.ToContext(context.Background()))
47
-
48
- err := handleWatchCard(cmd, "not-a-number")
49
- if err == nil {
50
- t.Errorf("expected error for invalid card number")
51
- }
52
- if err.Error() != "invalid card number: strconv.Atoi: parsing \"not-a-number\": invalid syntax" {
53
- t.Errorf("expected invalid card number error, got %v", err)
54
- }
55
- }
56
-
57
- func TestCardWatchCommandNoClient(t *testing.T) {
58
- testApp := &app.App{}
59
-
60
- cmd := cardWatchCmd
61
- cmd.SetContext(testApp.ToContext(context.Background()))
62
-
63
- err := handleWatchCard(cmd, "123")
64
- if err == nil {
65
- t.Errorf("expected error when client not available")
66
- }
67
- if err.Error() != "API client not available" {
68
- t.Errorf("expected 'client not available' error, got %v", err)
69
- }
70
- }
71
-
72
- func TestCardWatchCommandAPIError(t *testing.T) {
73
- server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
74
- w.WriteHeader(http.StatusInternalServerError)
75
- w.Write([]byte("Internal Server Error"))
76
- }))
77
- defer server.Close()
78
-
79
- client := testutil.NewTestClient(server.URL, "", "", "test-token")
80
- testApp := &app.App{Client: client}
81
-
82
- cmd := cardWatchCmd
83
- cmd.SetContext(testApp.ToContext(context.Background()))
84
-
85
- err := handleWatchCard(cmd, "123")
86
- if err == nil {
87
- t.Errorf("expected error for API failure")
88
- }
89
- if err.Error() != "watching card: unexpected status code 500: Internal Server Error" {
90
- t.Errorf("expected API error, got %v", err)
91
- }
92
- }
package/cmd/column.go DELETED
@@ -1,14 +0,0 @@
1
- // Package cmd
2
- package cmd
3
-
4
- import "github.com/spf13/cobra"
5
-
6
- var columnCmd = &cobra.Command{
7
- Use: "column",
8
- Short: "Manage columns",
9
- Long: `Manage columns in Fizzy`,
10
- }
11
-
12
- func init() {
13
- rootCmd.AddCommand(columnCmd)
14
- }
@@ -1,79 +0,0 @@
1
- package cmd
2
-
3
- import (
4
- "context"
5
- "fmt"
6
- "strings"
7
-
8
- "github.com/rogeriopvl/fizzy/internal/api"
9
- "github.com/rogeriopvl/fizzy/internal/app"
10
- "github.com/rogeriopvl/fizzy/internal/colors"
11
- "github.com/spf13/cobra"
12
- )
13
-
14
- func buildColorAliases() map[string]api.Color {
15
- aliases := make(map[string]api.Color)
16
- for _, colorDef := range colors.All {
17
- aliases[strings.ToLower(colorDef.Name)] = api.Color(colorDef.CSSValue)
18
- }
19
- return aliases
20
- }
21
-
22
- func getAvailableColors() string {
23
- var names []string
24
- for _, colorDef := range colors.All {
25
- names = append(names, strings.ToLower(colorDef.Name))
26
- }
27
- return strings.Join(names, ", ")
28
- }
29
-
30
- var columnCreateCmd = &cobra.Command{
31
- Use: "create",
32
- Short: "Create a new column",
33
- Long: `Create a new column in the selected board. Color is optional.`,
34
- Run: func(cmd *cobra.Command, args []string) {
35
- if err := handleCreateColumn(cmd); err != nil {
36
- fmt.Fprintf(cmd.OutOrStderr(), "Error: %v\n", err)
37
- }
38
- },
39
- }
40
-
41
- func handleCreateColumn(cmd *cobra.Command) error {
42
- a := app.FromContext(cmd.Context())
43
- if a == nil || a.Client == nil {
44
- return fmt.Errorf("API client not available")
45
- }
46
-
47
- // Read flag values directly from command
48
- name, _ := cmd.Flags().GetString("name")
49
- colorStr, _ := cmd.Flags().GetString("color")
50
-
51
- payload := api.CreateColumnPayload{
52
- Name: name,
53
- }
54
-
55
- if colorStr != "" {
56
- colorAliases := buildColorAliases()
57
- color, ok := colorAliases[colorStr]
58
- if !ok {
59
- return fmt.Errorf("invalid color '%s'. Available colors: %s", colorStr, getAvailableColors())
60
- }
61
- payload.Color = &color
62
- }
63
-
64
- _, err := a.Client.PostColumns(context.Background(), payload)
65
- if err != nil {
66
- return fmt.Errorf("creating column: %w", err)
67
- }
68
-
69
- fmt.Fprintf(cmd.OutOrStdout(), "✓ Column '%s' created successfully\n", name)
70
- return nil
71
- }
72
-
73
- func init() {
74
- columnCreateCmd.Flags().StringP("name", "n", "", "Column name (required)")
75
- columnCreateCmd.MarkFlagRequired("name")
76
- columnCreateCmd.Flags().String("color", "", fmt.Sprintf("Column color (optional). Available: %s", getAvailableColors()))
77
-
78
- columnCmd.AddCommand(columnCreateCmd)
79
- }
@@ -1,178 +0,0 @@
1
- package cmd
2
-
3
- import (
4
- "context"
5
- "encoding/json"
6
- "io"
7
- "net/http"
8
- "net/http/httptest"
9
- "testing"
10
-
11
- "github.com/rogeriopvl/fizzy/internal/api"
12
- "github.com/rogeriopvl/fizzy/internal/app"
13
- "github.com/rogeriopvl/fizzy/internal/testutil"
14
- )
15
-
16
- func TestColumnCreateCommandSuccess(t *testing.T) {
17
- server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
18
- if r.URL.Path != "/boards/board-123/columns" {
19
- t.Errorf("expected /boards/board-123/columns, got %s", r.URL.Path)
20
- }
21
- if r.Method != http.MethodPost {
22
- t.Errorf("expected POST, got %s", r.Method)
23
- }
24
-
25
- auth := r.Header.Get("Authorization")
26
- if auth != "Bearer test-token" {
27
- t.Errorf("expected Bearer test-token, got %s", auth)
28
- }
29
-
30
- if r.Header.Get("Content-Type") != "application/json" {
31
- t.Errorf("expected Content-Type: application/json, got %s", r.Header.Get("Content-Type"))
32
- }
33
-
34
- body, _ := io.ReadAll(r.Body)
35
- var payload map[string]api.CreateColumnPayload
36
- if err := json.Unmarshal(body, &payload); err != nil {
37
- t.Fatalf("failed to unmarshal request body: %v", err)
38
- }
39
-
40
- columnPayload := payload["column"]
41
- if columnPayload.Name != "Todo" {
42
- t.Errorf("expected name 'Todo', got %s", columnPayload.Name)
43
- }
44
- if columnPayload.Color != nil {
45
- t.Errorf("expected no color, got %v", columnPayload.Color)
46
- }
47
-
48
- w.WriteHeader(http.StatusCreated)
49
- w.Header().Set("Location", "/columns/col-123")
50
- }))
51
- defer server.Close()
52
-
53
- client := testutil.NewTestClient(server.URL, "", "board-123", "test-token")
54
- testApp := &app.App{Client: client}
55
-
56
- cmd := columnCreateCmd
57
- cmd.SetContext(testApp.ToContext(context.Background()))
58
- cmd.ParseFlags([]string{"--name", "Todo"})
59
-
60
- if err := handleCreateColumn(cmd); err != nil {
61
- t.Fatalf("handleCreateColumn failed: %v", err)
62
- }
63
- }
64
-
65
- func TestColumnCreateCommandWithColor(t *testing.T) {
66
- server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
67
- if r.Method != http.MethodPost {
68
- t.Errorf("expected POST, got %s", r.Method)
69
- }
70
-
71
- body, _ := io.ReadAll(r.Body)
72
- var payload map[string]api.CreateColumnPayload
73
- json.Unmarshal(body, &payload)
74
-
75
- columnPayload := payload["column"]
76
- if columnPayload.Name != "In Progress" {
77
- t.Errorf("expected name 'In Progress', got %s", columnPayload.Name)
78
- }
79
- if columnPayload.Color == nil {
80
- t.Error("expected color to be set")
81
- }
82
- if *columnPayload.Color != "var(--color-card-4)" {
83
- t.Errorf("expected color 'var(--color-card-4)', got %s", *columnPayload.Color)
84
- }
85
-
86
- w.WriteHeader(http.StatusCreated)
87
- }))
88
- defer server.Close()
89
-
90
- client := testutil.NewTestClient(server.URL, "", "board-123", "test-token")
91
- testApp := &app.App{Client: client}
92
-
93
- cmd := columnCreateCmd
94
- cmd.SetContext(testApp.ToContext(context.Background()))
95
- cmd.ParseFlags([]string{"--name", "In Progress", "--color", "lime"})
96
-
97
- if err := handleCreateColumn(cmd); err != nil {
98
- t.Fatalf("handleCreateColumn failed: %v", err)
99
- }
100
- }
101
-
102
- func TestColumnCreateCommandInvalidColor(t *testing.T) {
103
- client := testutil.NewTestClient("http://localhost", "", "board-123", "test-token")
104
- testApp := &app.App{Client: client}
105
-
106
- cmd := columnCreateCmd
107
- cmd.SetContext(testApp.ToContext(context.Background()))
108
- cmd.ParseFlags([]string{"--name", "Todo", "--color", "invalid"})
109
-
110
- err := handleCreateColumn(cmd)
111
- if err == nil {
112
- t.Errorf("expected error for invalid color")
113
- }
114
- if err.Error() != "invalid color 'invalid'. Available colors: blue, gray, tan, yellow, lime, aqua, violet, purple, pink" {
115
- t.Errorf("expected invalid color error, got %v", err)
116
- }
117
- }
118
-
119
- func TestColumnCreateCommandNoBoard(t *testing.T) {
120
- server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
121
- w.WriteHeader(http.StatusInternalServerError)
122
- }))
123
- defer server.Close()
124
-
125
- client := testutil.NewTestClient(server.URL, "", "", "test-token")
126
- testApp := &app.App{Client: client}
127
-
128
- cmd := columnCreateCmd
129
- cmd.SetContext(testApp.ToContext(context.Background()))
130
- cmd.ParseFlags([]string{"--name", "Todo", "--color", ""})
131
-
132
- err := handleCreateColumn(cmd)
133
- if err == nil {
134
- t.Errorf("expected error when board not selected")
135
- }
136
- if err.Error() != "creating column: please select a board first with 'fizzy use --board <board_name>'" {
137
- t.Errorf("expected 'board not selected' error, got %v", err)
138
- }
139
- }
140
-
141
- func TestColumnCreateCommandNoClient(t *testing.T) {
142
- testApp := &app.App{}
143
-
144
- cmd := columnCreateCmd
145
- cmd.SetContext(testApp.ToContext(context.Background()))
146
- cmd.ParseFlags([]string{"--name", "Todo", "--color", ""})
147
-
148
- err := handleCreateColumn(cmd)
149
- if err == nil {
150
- t.Errorf("expected error when client not available")
151
- }
152
- if err.Error() != "API client not available" {
153
- t.Errorf("expected 'client not available' error, got %v", err)
154
- }
155
- }
156
-
157
- func TestColumnCreateCommandAPIError(t *testing.T) {
158
- server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
159
- w.WriteHeader(http.StatusInternalServerError)
160
- w.Write([]byte("Internal Server Error"))
161
- }))
162
- defer server.Close()
163
-
164
- client := testutil.NewTestClient(server.URL, "", "board-123", "test-token")
165
- testApp := &app.App{Client: client}
166
-
167
- cmd := columnCreateCmd
168
- cmd.SetContext(testApp.ToContext(context.Background()))
169
- cmd.ParseFlags([]string{"--name", "Todo", "--color", ""})
170
-
171
- err := handleCreateColumn(cmd)
172
- if err == nil {
173
- t.Errorf("expected error for API failure")
174
- }
175
- if err.Error() != "creating column: unexpected status code 500: Internal Server Error" {
176
- t.Errorf("expected API error, got %v", err)
177
- }
178
- }
@@ -1,40 +0,0 @@
1
- package cmd
2
-
3
- import (
4
- "context"
5
- "fmt"
6
-
7
- "github.com/rogeriopvl/fizzy/internal/app"
8
- "github.com/spf13/cobra"
9
- )
10
-
11
- var columnDeleteCmd = &cobra.Command{
12
- Use: "delete <column_id>",
13
- Short: "Delete a column",
14
- Long: `Delete a column. Only board administrators can delete columns.`,
15
- Args: cobra.ExactArgs(1),
16
- Run: func(cmd *cobra.Command, args []string) {
17
- if err := handleDeleteColumn(cmd, args[0]); err != nil {
18
- fmt.Fprintf(cmd.OutOrStderr(), "Error: %v\n", err)
19
- }
20
- },
21
- }
22
-
23
- func handleDeleteColumn(cmd *cobra.Command, columnID string) error {
24
- a := app.FromContext(cmd.Context())
25
- if a == nil || a.Client == nil {
26
- return fmt.Errorf("API client not available")
27
- }
28
-
29
- err := a.Client.DeleteColumn(context.Background(), columnID)
30
- if err != nil {
31
- return fmt.Errorf("deleting column: %w", err)
32
- }
33
-
34
- fmt.Fprintf(cmd.OutOrStdout(), "✓ Column '%s' deleted successfully\n", columnID)
35
- return nil
36
- }
37
-
38
- func init() {
39
- columnCmd.AddCommand(columnDeleteCmd)
40
- }