fizzy-cli 0.8.0 → 1.0.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.
- package/.golangci.yml +56 -0
- package/IMPLEMENTATION_PLAN.md +58 -0
- package/docs/API.md +89 -0
- package/package.json +2 -1
- package/.env +0 -1
- package/.github/workflows/release.yml +0 -29
- package/.github/workflows/tests.yml +0 -24
- package/AGENTS.md +0 -33
- package/CHANGELOG.md +0 -194
- package/Makefile +0 -43
- package/bin/fizzy +0 -0
- package/cmd/account.go +0 -14
- package/cmd/account_list.go +0 -44
- package/cmd/account_list_test.go +0 -118
- package/cmd/board.go +0 -49
- package/cmd/board_create.go +0 -59
- package/cmd/board_create_test.go +0 -141
- package/cmd/board_delete.go +0 -40
- package/cmd/board_delete_test.go +0 -121
- package/cmd/board_list.go +0 -44
- package/cmd/board_list_test.go +0 -115
- package/cmd/board_show.go +0 -40
- package/cmd/board_show_test.go +0 -113
- package/cmd/board_test.go +0 -92
- package/cmd/board_update.go +0 -72
- package/cmd/board_update_test.go +0 -233
- package/cmd/card.go +0 -24
- package/cmd/card_assign.go +0 -55
- package/cmd/card_assign_test.go +0 -130
- package/cmd/card_close.go +0 -46
- package/cmd/card_close_test.go +0 -92
- package/cmd/card_create.go +0 -72
- package/cmd/card_create_test.go +0 -186
- package/cmd/card_delete.go +0 -46
- package/cmd/card_delete_test.go +0 -92
- package/cmd/card_golden.go +0 -46
- package/cmd/card_golden_test.go +0 -92
- package/cmd/card_list.go +0 -114
- package/cmd/card_list_test.go +0 -373
- package/cmd/card_not_now.go +0 -46
- package/cmd/card_not_now_test.go +0 -92
- package/cmd/card_reaction.go +0 -13
- package/cmd/card_reaction_create.go +0 -46
- package/cmd/card_reaction_create_test.go +0 -148
- package/cmd/card_reaction_delete.go +0 -46
- package/cmd/card_reaction_delete_test.go +0 -112
- package/cmd/card_reaction_list.go +0 -51
- package/cmd/card_reaction_list_test.go +0 -127
- package/cmd/card_reopen.go +0 -46
- package/cmd/card_reopen_test.go +0 -92
- package/cmd/card_show.go +0 -46
- package/cmd/card_show_test.go +0 -92
- package/cmd/card_tag.go +0 -51
- package/cmd/card_tag_test.go +0 -112
- package/cmd/card_triage.go +0 -46
- package/cmd/card_ungolden.go +0 -46
- package/cmd/card_ungolden_test.go +0 -92
- package/cmd/card_untriage.go +0 -46
- package/cmd/card_untriage_test.go +0 -92
- package/cmd/card_unwatch.go +0 -46
- package/cmd/card_unwatch_test.go +0 -92
- package/cmd/card_update.go +0 -82
- package/cmd/card_update_test.go +0 -149
- package/cmd/card_watch.go +0 -46
- package/cmd/card_watch_test.go +0 -92
- package/cmd/column.go +0 -14
- package/cmd/column_create.go +0 -79
- package/cmd/column_create_test.go +0 -178
- package/cmd/column_delete.go +0 -40
- package/cmd/column_delete_test.go +0 -121
- package/cmd/column_list.go +0 -44
- package/cmd/column_list_test.go +0 -138
- package/cmd/column_show.go +0 -40
- package/cmd/column_show_test.go +0 -111
- package/cmd/column_update.go +0 -67
- package/cmd/column_update_test.go +0 -198
- package/cmd/comment.go +0 -14
- package/cmd/comment_create.go +0 -51
- package/cmd/comment_create_test.go +0 -129
- package/cmd/comment_delete.go +0 -46
- package/cmd/comment_delete_test.go +0 -92
- package/cmd/comment_list.go +0 -51
- package/cmd/comment_list_test.go +0 -132
- package/cmd/comment_show.go +0 -46
- package/cmd/comment_show_test.go +0 -104
- package/cmd/comment_update.go +0 -51
- package/cmd/comment_update_test.go +0 -130
- package/cmd/login.go +0 -81
- package/cmd/login_test.go +0 -98
- package/cmd/notification.go +0 -14
- package/cmd/notification_list.go +0 -69
- package/cmd/notification_list_test.go +0 -288
- package/cmd/notification_read.go +0 -51
- package/cmd/notification_read_all.go +0 -38
- package/cmd/notification_read_all_test.go +0 -75
- package/cmd/notification_read_test.go +0 -138
- package/cmd/notification_unread.go +0 -44
- package/cmd/notification_unread_test.go +0 -99
- package/cmd/reaction.go +0 -13
- package/cmd/reaction_create.go +0 -46
- package/cmd/reaction_create_test.go +0 -113
- package/cmd/reaction_delete.go +0 -46
- package/cmd/reaction_delete_test.go +0 -92
- package/cmd/reaction_list.go +0 -51
- package/cmd/reaction_list_test.go +0 -125
- package/cmd/root.go +0 -38
- package/cmd/step.go +0 -14
- package/cmd/step_create.go +0 -53
- package/cmd/step_create_test.go +0 -171
- package/cmd/step_delete.go +0 -46
- package/cmd/step_delete_test.go +0 -92
- package/cmd/step_update.go +0 -66
- package/cmd/step_update_test.go +0 -190
- package/cmd/tag.go +0 -15
- package/cmd/tag_list.go +0 -47
- package/cmd/tag_list_test.go +0 -109
- package/cmd/use.go +0 -85
- package/cmd/use_test.go +0 -186
- package/cmd/user.go +0 -22
- package/cmd/user_deactivate.go +0 -40
- package/cmd/user_deactivate_test.go +0 -121
- package/cmd/user_list.go +0 -44
- package/cmd/user_list_test.go +0 -126
- package/cmd/user_show.go +0 -40
- package/cmd/user_show_test.go +0 -110
- package/cmd/user_update.go +0 -71
- package/cmd/user_update_test.go +0 -177
- package/go.mod +0 -31
- package/go.sum +0 -53
- package/internal/api/boards.go +0 -93
- package/internal/api/cards.go +0 -322
- package/internal/api/client.go +0 -99
- package/internal/api/columns.go +0 -113
- package/internal/api/comments.go +0 -108
- package/internal/api/identity.go +0 -24
- package/internal/api/notifications.go +0 -89
- package/internal/api/reactions.go +0 -130
- package/internal/api/steps.go +0 -101
- package/internal/api/tags.go +0 -24
- package/internal/api/types.go +0 -195
- package/internal/api/users.go +0 -75
- package/internal/app/app.go +0 -49
- package/internal/colors/colors.go +0 -32
- package/internal/config/config.go +0 -70
- package/internal/testutil/client.go +0 -26
- package/internal/ui/account_list.go +0 -14
- package/internal/ui/account_selector.go +0 -63
- package/internal/ui/board_list.go +0 -14
- package/internal/ui/board_show.go +0 -17
- package/internal/ui/card_list.go +0 -14
- package/internal/ui/card_show.go +0 -23
- package/internal/ui/column_list.go +0 -28
- package/internal/ui/column_show.go +0 -16
- package/internal/ui/comment_list.go +0 -25
- package/internal/ui/format.go +0 -27
- package/internal/ui/notification_list.go +0 -27
- package/internal/ui/reaction_list.go +0 -14
- package/internal/ui/user_list.go +0 -19
- package/internal/ui/user_show.go +0 -23
package/cmd/board_show.go
DELETED
|
@@ -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/rogeriopvl/fizzy/internal/ui"
|
|
9
|
-
"github.com/spf13/cobra"
|
|
10
|
-
)
|
|
11
|
-
|
|
12
|
-
var boardShowCmd = &cobra.Command{
|
|
13
|
-
Use: "show <board_id>",
|
|
14
|
-
Short: "Show board details",
|
|
15
|
-
Long: `Retrieve and display detailed information about a specific board`,
|
|
16
|
-
Args: cobra.ExactArgs(1),
|
|
17
|
-
Run: func(cmd *cobra.Command, args []string) {
|
|
18
|
-
if err := handleShowBoardDetails(cmd, args[0]); err != nil {
|
|
19
|
-
fmt.Fprintf(cmd.OutOrStderr(), "Error: %v\n", err)
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
func handleShowBoardDetails(cmd *cobra.Command, boardID string) error {
|
|
25
|
-
a := app.FromContext(cmd.Context())
|
|
26
|
-
if a == nil || a.Client == nil {
|
|
27
|
-
return fmt.Errorf("API client not available")
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
board, err := a.Client.GetBoard(context.Background(), boardID)
|
|
31
|
-
if err != nil {
|
|
32
|
-
return fmt.Errorf("fetching board: %w", err)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return ui.DisplayBoard(cmd.OutOrStdout(), board)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
func init() {
|
|
39
|
-
boardCmd.AddCommand(boardShowCmd)
|
|
40
|
-
}
|
package/cmd/board_show_test.go
DELETED
|
@@ -1,113 +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
|
-
)
|
|
14
|
-
|
|
15
|
-
func TestBoardShowCommandSuccess(t *testing.T) {
|
|
16
|
-
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
17
|
-
if r.URL.Path != "/boards/board-123" {
|
|
18
|
-
t.Errorf("expected /boards/board-123, got %s", r.URL.Path)
|
|
19
|
-
}
|
|
20
|
-
if r.Method != http.MethodGet {
|
|
21
|
-
t.Errorf("expected GET, got %s", r.Method)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
auth := r.Header.Get("Authorization")
|
|
25
|
-
if auth != "Bearer test-token" {
|
|
26
|
-
t.Errorf("expected Bearer test-token, got %s", auth)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
w.Header().Set("Content-Type", "application/json")
|
|
30
|
-
response := api.Board{
|
|
31
|
-
ID: "board-123",
|
|
32
|
-
Name: "Project Alpha",
|
|
33
|
-
AllAccess: true,
|
|
34
|
-
CreatedAt: "2025-01-01T00:00:00Z",
|
|
35
|
-
Creator: api.User{
|
|
36
|
-
ID: "user-123",
|
|
37
|
-
Name: "John Doe",
|
|
38
|
-
Role: "owner",
|
|
39
|
-
},
|
|
40
|
-
}
|
|
41
|
-
json.NewEncoder(w).Encode(response)
|
|
42
|
-
}))
|
|
43
|
-
defer server.Close()
|
|
44
|
-
|
|
45
|
-
client := testutil.NewTestClient(server.URL, "", "", "test-token")
|
|
46
|
-
testApp := &app.App{Client: client}
|
|
47
|
-
|
|
48
|
-
cmd := boardShowCmd
|
|
49
|
-
cmd.SetContext(testApp.ToContext(context.Background()))
|
|
50
|
-
|
|
51
|
-
if err := handleShowBoardDetails(cmd, "board-123"); err != nil {
|
|
52
|
-
t.Fatalf("handleShowBoardDetails failed: %v", err)
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
func TestBoardShowCommandNotFound(t *testing.T) {
|
|
57
|
-
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
58
|
-
w.WriteHeader(http.StatusNotFound)
|
|
59
|
-
w.Write([]byte("Board not found"))
|
|
60
|
-
}))
|
|
61
|
-
defer server.Close()
|
|
62
|
-
|
|
63
|
-
client := testutil.NewTestClient(server.URL, "", "", "test-token")
|
|
64
|
-
testApp := &app.App{Client: client}
|
|
65
|
-
|
|
66
|
-
cmd := boardShowCmd
|
|
67
|
-
cmd.SetContext(testApp.ToContext(context.Background()))
|
|
68
|
-
|
|
69
|
-
err := handleShowBoardDetails(cmd, "nonexistent-board")
|
|
70
|
-
if err == nil {
|
|
71
|
-
t.Errorf("expected error for board not found")
|
|
72
|
-
}
|
|
73
|
-
if err.Error() != "fetching board: unexpected status code 404: Board not found" {
|
|
74
|
-
t.Errorf("expected board not found error, got %v", err)
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
func TestBoardShowCommandAPIError(t *testing.T) {
|
|
79
|
-
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
80
|
-
w.WriteHeader(http.StatusInternalServerError)
|
|
81
|
-
w.Write([]byte("Internal Server Error"))
|
|
82
|
-
}))
|
|
83
|
-
defer server.Close()
|
|
84
|
-
|
|
85
|
-
client := testutil.NewTestClient(server.URL, "", "", "test-token")
|
|
86
|
-
testApp := &app.App{Client: client}
|
|
87
|
-
|
|
88
|
-
cmd := boardShowCmd
|
|
89
|
-
cmd.SetContext(testApp.ToContext(context.Background()))
|
|
90
|
-
|
|
91
|
-
err := handleShowBoardDetails(cmd, "board-123")
|
|
92
|
-
if err == nil {
|
|
93
|
-
t.Errorf("expected error for API failure")
|
|
94
|
-
}
|
|
95
|
-
if err.Error() != "fetching board: unexpected status code 500: Internal Server Error" {
|
|
96
|
-
t.Errorf("expected API error, got %v", err)
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
func TestBoardShowCommandNoClient(t *testing.T) {
|
|
101
|
-
testApp := &app.App{}
|
|
102
|
-
|
|
103
|
-
cmd := boardShowCmd
|
|
104
|
-
cmd.SetContext(testApp.ToContext(context.Background()))
|
|
105
|
-
|
|
106
|
-
err := handleShowBoardDetails(cmd, "board-123")
|
|
107
|
-
if err == nil {
|
|
108
|
-
t.Errorf("expected error when client not available")
|
|
109
|
-
}
|
|
110
|
-
if err.Error() != "API client not available" {
|
|
111
|
-
t.Errorf("expected 'client not available' error, got %v", err)
|
|
112
|
-
}
|
|
113
|
-
}
|
package/cmd/board_test.go
DELETED
|
@@ -1,92 +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/config"
|
|
13
|
-
"github.com/rogeriopvl/fizzy/internal/testutil"
|
|
14
|
-
)
|
|
15
|
-
|
|
16
|
-
func TestBoardCommand(t *testing.T) {
|
|
17
|
-
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
18
|
-
if r.URL.Path != "/boards/board-123" {
|
|
19
|
-
t.Errorf("expected /boards/board-123, got %s", r.URL.Path)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
w.Header().Set("Content-Type", "application/json")
|
|
23
|
-
response := api.Board{
|
|
24
|
-
ID: "board-123",
|
|
25
|
-
Name: "Test Board",
|
|
26
|
-
AllAccess: true,
|
|
27
|
-
CreatedAt: "2025-12-05T19:36:35.534Z",
|
|
28
|
-
}
|
|
29
|
-
json.NewEncoder(w).Encode(response)
|
|
30
|
-
}))
|
|
31
|
-
defer server.Close()
|
|
32
|
-
|
|
33
|
-
client := testutil.NewTestClient(server.URL, "", "", "test-token")
|
|
34
|
-
testApp := &app.App{
|
|
35
|
-
Client: client,
|
|
36
|
-
Config: &config.Config{
|
|
37
|
-
SelectedBoard: "board-123",
|
|
38
|
-
},
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
cmd := boardCmd
|
|
42
|
-
cmd.SetContext(testApp.ToContext(context.Background()))
|
|
43
|
-
|
|
44
|
-
if err := handleShowBoard(cmd); err != nil {
|
|
45
|
-
t.Fatalf("handleShowBoard failed: %v", err)
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
func TestBoardCommandNoBoard(t *testing.T) {
|
|
50
|
-
client := testutil.NewTestClient("http://localhost", "", "", "test-token")
|
|
51
|
-
testApp := &app.App{
|
|
52
|
-
Client: client,
|
|
53
|
-
Config: &config.Config{
|
|
54
|
-
SelectedBoard: "",
|
|
55
|
-
},
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
cmd := boardCmd
|
|
59
|
-
cmd.SetContext(testApp.ToContext(context.Background()))
|
|
60
|
-
|
|
61
|
-
err := handleShowBoard(cmd)
|
|
62
|
-
if err == nil {
|
|
63
|
-
t.Errorf("expected error when no board selected")
|
|
64
|
-
}
|
|
65
|
-
if err.Error() != "no board selected" {
|
|
66
|
-
t.Errorf("expected 'no board selected' error, got %v", err)
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
func TestBoardCommandAPIError(t *testing.T) {
|
|
71
|
-
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
72
|
-
w.WriteHeader(http.StatusInternalServerError)
|
|
73
|
-
w.Write([]byte("Internal Server Error"))
|
|
74
|
-
}))
|
|
75
|
-
defer server.Close()
|
|
76
|
-
|
|
77
|
-
client := testutil.NewTestClient(server.URL, "", "", "test-token")
|
|
78
|
-
testApp := &app.App{
|
|
79
|
-
Client: client,
|
|
80
|
-
Config: &config.Config{
|
|
81
|
-
SelectedBoard: "board-123",
|
|
82
|
-
},
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
cmd := boardCmd
|
|
86
|
-
cmd.SetContext(testApp.ToContext(context.Background()))
|
|
87
|
-
|
|
88
|
-
err := handleShowBoard(cmd)
|
|
89
|
-
if err == nil {
|
|
90
|
-
t.Errorf("expected error for API failure")
|
|
91
|
-
}
|
|
92
|
-
}
|
package/cmd/board_update.go
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
package cmd
|
|
2
|
-
|
|
3
|
-
import (
|
|
4
|
-
"context"
|
|
5
|
-
"fmt"
|
|
6
|
-
|
|
7
|
-
"github.com/rogeriopvl/fizzy/internal/api"
|
|
8
|
-
"github.com/rogeriopvl/fizzy/internal/app"
|
|
9
|
-
"github.com/spf13/cobra"
|
|
10
|
-
)
|
|
11
|
-
|
|
12
|
-
var boardUpdateCmd = &cobra.Command{
|
|
13
|
-
Use: "update <board_id>",
|
|
14
|
-
Short: "Update a board",
|
|
15
|
-
Long: `Update board settings such as name, access permissions, and auto-postpone period`,
|
|
16
|
-
Args: cobra.ExactArgs(1),
|
|
17
|
-
Run: func(cmd *cobra.Command, args []string) {
|
|
18
|
-
if err := handleUpdateBoard(cmd, args[0]); err != nil {
|
|
19
|
-
fmt.Fprintf(cmd.OutOrStderr(), "Error: %v\n", err)
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
func handleUpdateBoard(cmd *cobra.Command, boardID string) error {
|
|
25
|
-
// Check that at least one flag was explicitly set
|
|
26
|
-
if !cmd.Flags().Changed("name") && !cmd.Flags().Changed("all-access") &&
|
|
27
|
-
!cmd.Flags().Changed("auto-postpone-period") && !cmd.Flags().Changed("description") {
|
|
28
|
-
return fmt.Errorf("at least one flag must be provided (--name, --all-access, --auto-postpone-period, or --description)")
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
a := app.FromContext(cmd.Context())
|
|
32
|
-
if a == nil || a.Client == nil {
|
|
33
|
-
return fmt.Errorf("API client not available")
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// Build payload only with flags that were explicitly set
|
|
37
|
-
payload := api.UpdateBoardPayload{}
|
|
38
|
-
|
|
39
|
-
if cmd.Flags().Changed("name") {
|
|
40
|
-
name, _ := cmd.Flags().GetString("name")
|
|
41
|
-
payload.Name = name
|
|
42
|
-
}
|
|
43
|
-
if cmd.Flags().Changed("all-access") {
|
|
44
|
-
allAccess, _ := cmd.Flags().GetBool("all-access")
|
|
45
|
-
payload.AllAccess = &allAccess
|
|
46
|
-
}
|
|
47
|
-
if cmd.Flags().Changed("auto-postpone-period") {
|
|
48
|
-
autoPostponePeriod, _ := cmd.Flags().GetInt("auto-postpone-period")
|
|
49
|
-
payload.AutoPostponePeriod = &autoPostponePeriod
|
|
50
|
-
}
|
|
51
|
-
if cmd.Flags().Changed("description") {
|
|
52
|
-
publicDescription, _ := cmd.Flags().GetString("description")
|
|
53
|
-
payload.PublicDescription = publicDescription
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
err := a.Client.PutBoard(context.Background(), boardID, payload)
|
|
57
|
-
if err != nil {
|
|
58
|
-
return fmt.Errorf("updating board: %w", err)
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
fmt.Fprintf(cmd.OutOrStdout(), "✓ Board '%s' updated successfully\n", boardID)
|
|
62
|
-
return nil
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
func init() {
|
|
66
|
-
boardUpdateCmd.Flags().StringP("name", "n", "", "Board name")
|
|
67
|
-
boardUpdateCmd.Flags().Bool("all-access", false, "Allow all access to the board")
|
|
68
|
-
boardUpdateCmd.Flags().Int("auto-postpone-period", 0, "Auto postpone period in days")
|
|
69
|
-
boardUpdateCmd.Flags().String("description", "", "Public description of the board")
|
|
70
|
-
|
|
71
|
-
boardCmd.AddCommand(boardUpdateCmd)
|
|
72
|
-
}
|
package/cmd/board_update_test.go
DELETED
|
@@ -1,233 +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
|
-
"github.com/spf13/cobra"
|
|
15
|
-
)
|
|
16
|
-
|
|
17
|
-
func TestBoardUpdateCommandSuccess(t *testing.T) {
|
|
18
|
-
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
19
|
-
if r.URL.Path != "/boards/board-123" {
|
|
20
|
-
t.Errorf("expected /boards/board-123, got %s", r.URL.Path)
|
|
21
|
-
}
|
|
22
|
-
if r.Method != http.MethodPut {
|
|
23
|
-
t.Errorf("expected PUT, got %s", r.Method)
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
auth := r.Header.Get("Authorization")
|
|
27
|
-
if auth != "Bearer test-token" {
|
|
28
|
-
t.Errorf("expected Bearer test-token, got %s", auth)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
body, _ := io.ReadAll(r.Body)
|
|
32
|
-
var payload map[string]api.UpdateBoardPayload
|
|
33
|
-
if err := json.Unmarshal(body, &payload); err != nil {
|
|
34
|
-
t.Fatalf("failed to unmarshal request body: %v", err)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
boardPayload := payload["board"]
|
|
38
|
-
if boardPayload.Name != "Updated Board" {
|
|
39
|
-
t.Errorf("expected name 'Updated Board', got %s", boardPayload.Name)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
w.WriteHeader(http.StatusNoContent)
|
|
43
|
-
}))
|
|
44
|
-
defer server.Close()
|
|
45
|
-
|
|
46
|
-
client := testutil.NewTestClient(server.URL, "", "", "test-token")
|
|
47
|
-
testApp := &app.App{Client: client}
|
|
48
|
-
|
|
49
|
-
cmd := boardUpdateCmd
|
|
50
|
-
cmd.SetContext(testApp.ToContext(context.Background()))
|
|
51
|
-
cmd.ParseFlags([]string{"--name", "Updated Board"})
|
|
52
|
-
|
|
53
|
-
if err := handleUpdateBoard(cmd, "board-123"); err != nil {
|
|
54
|
-
t.Fatalf("handleUpdateBoard failed: %v", err)
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
func TestBoardUpdateCommandWithAllFlags(t *testing.T) {
|
|
59
|
-
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
60
|
-
if r.Method != http.MethodPut {
|
|
61
|
-
t.Errorf("expected PUT, got %s", r.Method)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
body, _ := io.ReadAll(r.Body)
|
|
65
|
-
var payload map[string]api.UpdateBoardPayload
|
|
66
|
-
json.Unmarshal(body, &payload)
|
|
67
|
-
|
|
68
|
-
boardPayload := payload["board"]
|
|
69
|
-
if boardPayload.Name != "Updated Board" {
|
|
70
|
-
t.Errorf("expected name 'Updated Board', got %s", boardPayload.Name)
|
|
71
|
-
}
|
|
72
|
-
if boardPayload.AllAccess == nil || !*boardPayload.AllAccess {
|
|
73
|
-
t.Error("expected AllAccess to be pointer to true")
|
|
74
|
-
}
|
|
75
|
-
if boardPayload.AutoPostponePeriod == nil || *boardPayload.AutoPostponePeriod != 14 {
|
|
76
|
-
t.Errorf("expected AutoPostponePeriod pointer to 14, got %v", boardPayload.AutoPostponePeriod)
|
|
77
|
-
}
|
|
78
|
-
if boardPayload.PublicDescription != "Updated description" {
|
|
79
|
-
t.Errorf("expected description 'Updated description', got %s", boardPayload.PublicDescription)
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
w.WriteHeader(http.StatusNoContent)
|
|
83
|
-
}))
|
|
84
|
-
defer server.Close()
|
|
85
|
-
|
|
86
|
-
client := testutil.NewTestClient(server.URL, "", "", "test-token")
|
|
87
|
-
testApp := &app.App{Client: client}
|
|
88
|
-
|
|
89
|
-
cmd := boardUpdateCmd
|
|
90
|
-
cmd.SetContext(testApp.ToContext(context.Background()))
|
|
91
|
-
cmd.ParseFlags([]string{
|
|
92
|
-
"--name", "Updated Board",
|
|
93
|
-
"--all-access",
|
|
94
|
-
"--auto-postpone-period", "14",
|
|
95
|
-
"--description", "Updated description",
|
|
96
|
-
})
|
|
97
|
-
|
|
98
|
-
if err := handleUpdateBoard(cmd, "board-123"); err != nil {
|
|
99
|
-
t.Fatalf("handleUpdateBoard failed: %v", err)
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
func TestBoardUpdateCommandZeroValues(t *testing.T) {
|
|
104
|
-
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
105
|
-
if r.Method != http.MethodPut {
|
|
106
|
-
t.Errorf("expected PUT, got %s", r.Method)
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
body, _ := io.ReadAll(r.Body)
|
|
110
|
-
var payload map[string]api.UpdateBoardPayload
|
|
111
|
-
json.Unmarshal(body, &payload)
|
|
112
|
-
|
|
113
|
-
boardPayload := payload["board"]
|
|
114
|
-
// Verify that false value is sent (not omitted)
|
|
115
|
-
if boardPayload.AllAccess == nil {
|
|
116
|
-
t.Error("expected AllAccess to be set (pointer), but got nil")
|
|
117
|
-
}
|
|
118
|
-
if *boardPayload.AllAccess != false {
|
|
119
|
-
t.Error("expected AllAccess to be false")
|
|
120
|
-
}
|
|
121
|
-
// Verify that 0 value is sent (not omitted)
|
|
122
|
-
if boardPayload.AutoPostponePeriod == nil {
|
|
123
|
-
t.Error("expected AutoPostponePeriod to be set (pointer), but got nil")
|
|
124
|
-
}
|
|
125
|
-
if *boardPayload.AutoPostponePeriod != 0 {
|
|
126
|
-
t.Errorf("expected AutoPostponePeriod to be 0, got %d", *boardPayload.AutoPostponePeriod)
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
w.WriteHeader(http.StatusNoContent)
|
|
130
|
-
}))
|
|
131
|
-
defer server.Close()
|
|
132
|
-
|
|
133
|
-
client := testutil.NewTestClient(server.URL, "", "", "test-token")
|
|
134
|
-
testApp := &app.App{Client: client}
|
|
135
|
-
|
|
136
|
-
cmd := boardUpdateCmd
|
|
137
|
-
cmd.SetContext(testApp.ToContext(context.Background()))
|
|
138
|
-
cmd.ParseFlags([]string{
|
|
139
|
-
"--all-access=false",
|
|
140
|
-
"--auto-postpone-period", "0",
|
|
141
|
-
})
|
|
142
|
-
|
|
143
|
-
if err := handleUpdateBoard(cmd, "board-123"); err != nil {
|
|
144
|
-
t.Fatalf("handleUpdateBoard failed: %v", err)
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
func TestBoardUpdateCommandNoFlags(t *testing.T) {
|
|
149
|
-
client := testutil.NewTestClient("http://localhost", "", "", "test-token")
|
|
150
|
-
testApp := &app.App{Client: client}
|
|
151
|
-
|
|
152
|
-
// Create a fresh command to avoid flag pollution from other tests
|
|
153
|
-
cmd := &cobra.Command{
|
|
154
|
-
Use: "update <board_id>",
|
|
155
|
-
Args: cobra.ExactArgs(1),
|
|
156
|
-
}
|
|
157
|
-
cmd.Flags().String("name", "", "Board name")
|
|
158
|
-
cmd.Flags().Bool("all-access", false, "Allow all access to the board")
|
|
159
|
-
cmd.Flags().Int("auto-postpone-period", 0, "Auto postpone period in days")
|
|
160
|
-
cmd.Flags().String("description", "", "Public description of the board")
|
|
161
|
-
|
|
162
|
-
cmd.SetContext(testApp.ToContext(context.Background()))
|
|
163
|
-
|
|
164
|
-
err := handleUpdateBoard(cmd, "board-123")
|
|
165
|
-
if err == nil {
|
|
166
|
-
t.Errorf("expected error when no flags provided")
|
|
167
|
-
}
|
|
168
|
-
if err.Error() != "at least one flag must be provided (--name, --all-access, --auto-postpone-period, or --description)" {
|
|
169
|
-
t.Errorf("expected flag requirement error, got %v", err)
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
func TestBoardUpdateCommandNotFound(t *testing.T) {
|
|
174
|
-
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
175
|
-
w.WriteHeader(http.StatusNotFound)
|
|
176
|
-
w.Write([]byte("Board not found"))
|
|
177
|
-
}))
|
|
178
|
-
defer server.Close()
|
|
179
|
-
|
|
180
|
-
client := testutil.NewTestClient(server.URL, "", "", "test-token")
|
|
181
|
-
testApp := &app.App{Client: client}
|
|
182
|
-
|
|
183
|
-
cmd := boardUpdateCmd
|
|
184
|
-
cmd.SetContext(testApp.ToContext(context.Background()))
|
|
185
|
-
cmd.ParseFlags([]string{"--name", "Updated Board"})
|
|
186
|
-
|
|
187
|
-
err := handleUpdateBoard(cmd, "nonexistent-board")
|
|
188
|
-
if err == nil {
|
|
189
|
-
t.Errorf("expected error for board not found")
|
|
190
|
-
}
|
|
191
|
-
if err.Error() != "updating board: unexpected status code 404: Board not found" {
|
|
192
|
-
t.Errorf("expected board not found error, got %v", err)
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
func TestBoardUpdateCommandAPIError(t *testing.T) {
|
|
197
|
-
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
198
|
-
w.WriteHeader(http.StatusInternalServerError)
|
|
199
|
-
w.Write([]byte("Internal Server Error"))
|
|
200
|
-
}))
|
|
201
|
-
defer server.Close()
|
|
202
|
-
|
|
203
|
-
client := testutil.NewTestClient(server.URL, "", "", "test-token")
|
|
204
|
-
testApp := &app.App{Client: client}
|
|
205
|
-
|
|
206
|
-
cmd := boardUpdateCmd
|
|
207
|
-
cmd.SetContext(testApp.ToContext(context.Background()))
|
|
208
|
-
cmd.ParseFlags([]string{"--name", "Updated Board"})
|
|
209
|
-
|
|
210
|
-
err := handleUpdateBoard(cmd, "board-123")
|
|
211
|
-
if err == nil {
|
|
212
|
-
t.Errorf("expected error for API failure")
|
|
213
|
-
}
|
|
214
|
-
if err.Error() != "updating board: unexpected status code 500: Internal Server Error" {
|
|
215
|
-
t.Errorf("expected API error, got %v", err)
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
func TestBoardUpdateCommandNoClient(t *testing.T) {
|
|
220
|
-
testApp := &app.App{}
|
|
221
|
-
|
|
222
|
-
cmd := boardUpdateCmd
|
|
223
|
-
cmd.SetContext(testApp.ToContext(context.Background()))
|
|
224
|
-
cmd.ParseFlags([]string{"--name", "Updated Board"})
|
|
225
|
-
|
|
226
|
-
err := handleUpdateBoard(cmd, "board-123")
|
|
227
|
-
if err == nil {
|
|
228
|
-
t.Errorf("expected error when client not available")
|
|
229
|
-
}
|
|
230
|
-
if err.Error() != "API client not available" {
|
|
231
|
-
t.Errorf("expected 'client not available' error, got %v", err)
|
|
232
|
-
}
|
|
233
|
-
}
|
package/cmd/card.go
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
// Package cmd
|
|
2
|
-
package cmd
|
|
3
|
-
|
|
4
|
-
import "github.com/spf13/cobra"
|
|
5
|
-
|
|
6
|
-
var cardCmd = &cobra.Command{
|
|
7
|
-
Use: "card",
|
|
8
|
-
Short: "Manage cards",
|
|
9
|
-
Long: `Manage cards in Fizzy`,
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
func init() {
|
|
13
|
-
rootCmd.AddCommand(cardCmd)
|
|
14
|
-
|
|
15
|
-
// Here you will define your flags and configuration settings.
|
|
16
|
-
|
|
17
|
-
// Cobra supports Persistent Flags which will work for this command
|
|
18
|
-
// and all subcommands, e.g.:
|
|
19
|
-
// cardsCmd.PersistentFlags().String("foo", "", "A help for foo")
|
|
20
|
-
|
|
21
|
-
// Cobra supports local flags which will only run when this command
|
|
22
|
-
// is called directly, e.g.:
|
|
23
|
-
// cardsCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
|
24
|
-
}
|
package/cmd/card_assign.go
DELETED
|
@@ -1,55 +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 cardAssignCmd = &cobra.Command{
|
|
13
|
-
Use: "assign <card_number> <user_id>",
|
|
14
|
-
Short: "Assign a user to a card",
|
|
15
|
-
Long: `Assign or unassign a user to/from a card.
|
|
16
|
-
|
|
17
|
-
Use "me" as the user_id to assign the card to yourself.`,
|
|
18
|
-
Args: cobra.ExactArgs(2),
|
|
19
|
-
Run: func(cmd *cobra.Command, args []string) {
|
|
20
|
-
if err := handleAssignCard(cmd, args[0], args[1]); err != nil {
|
|
21
|
-
fmt.Fprintf(cmd.OutOrStderr(), "Error: %v\n", err)
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
func handleAssignCard(cmd *cobra.Command, cardNumber, userID string) error {
|
|
27
|
-
cardNum, err := strconv.Atoi(cardNumber)
|
|
28
|
-
if err != nil {
|
|
29
|
-
return fmt.Errorf("invalid card number: %w", err)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
a := app.FromContext(cmd.Context())
|
|
33
|
-
if a == nil || a.Client == nil {
|
|
34
|
-
return fmt.Errorf("API client not available")
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if userID == "me" {
|
|
38
|
-
if a.Config.CurrentUserID == "" {
|
|
39
|
-
return fmt.Errorf("current user ID not available, please run 'fizzy login' first")
|
|
40
|
-
}
|
|
41
|
-
userID = a.Config.CurrentUserID
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
_, err = a.Client.PostCardAssignments(context.Background(), cardNum, userID)
|
|
45
|
-
if err != nil {
|
|
46
|
-
return fmt.Errorf("assigning card: %w", err)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
fmt.Fprintf(cmd.OutOrStdout(), "✓ Card #%d assignment toggled for user %s\n", cardNum, userID)
|
|
50
|
-
return nil
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
func init() {
|
|
54
|
-
cardCmd.AddCommand(cardAssignCmd)
|
|
55
|
-
}
|