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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/flashcatcloud/flashduty-cli
go 1.26.0

require (
github.com/flashcatcloud/go-flashduty v0.15.17
github.com/flashcatcloud/go-flashduty v0.15.18-0.20261015103612-f84d9ddaca1a
github.com/mattn/go-runewidth v0.0.30
github.com/spf13/cobra v1.10.2
github.com/spf13/pflag v1.0.10
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
github.com/clipperhouse/uax29/v2 v2.2.0 h1:ChwIKnQN3kcZteTXMgb1wztSgaU+ZemkgWdohwgs8tY=
github.com/clipperhouse/uax29/v2 v2.2.0/go.mod h1:EFJ2TJMRUaplDxHKj1qAEhCtQPW2tJSwu5BF98AuoVM=
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
github.com/flashcatcloud/go-flashduty v0.15.17 h1:AkWSRYEUdMMYAI7WJbzHIHBnZ+FqcbMAwK8aInOOLpI=
github.com/flashcatcloud/go-flashduty v0.15.17/go.mod h1:YpHiTYXR5NXBI/rGRZfUy537XMkhdCkwA8NW1QoRHwk=
github.com/flashcatcloud/go-flashduty v0.15.18-0.20261015103612-f84d9ddaca1a h1:+oqnFVWaZlC7yGMu+wl0QpBwEOGdOG+a6hFagXSHYuM=
github.com/flashcatcloud/go-flashduty v0.15.18-0.20261015103612-f84d9ddaca1a/go.mod h1:YpHiTYXR5NXBI/rGRZfUy537XMkhdCkwA8NW1QoRHwk=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/mattn/go-runewidth v0.0.30 h1:+KUuiDA4fF0R1p5FeueHefjDm+GIM+kWfFnDjybOPgk=
Expand Down
55 changes: 55 additions & 0 deletions internal/cli/folders_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package cli

import (
"reflect"
"strings"
"testing"
)

func TestFolderCommands(t *testing.T) {
for _, tt := range []struct {
action string
args []string
body map[string]any
}{
{"list", nil, nil},
{"health", nil, nil},
{"create", []string{"--name", "Checkout", "--parent-id", "10"}, map[string]any{"name": "Checkout", "parent_id": float64(10)}},
{"update", []string{"--id", "12", "--name", "Checkout", "--note", "", "--team-id", "0"}, map[string]any{"id": float64(12), "name": "Checkout"}},
{"move", []string{"--id", "12", "--dest-parent-id", "0"}, map[string]any{"id": float64(12), "dest_parent_id": float64(0)}},
{"delete", []string{"--id", "12"}, map[string]any{"id": float64(12)}},
} {
t.Run(tt.action, func(t *testing.T) {
saveAndResetGlobals(t)
stub := newGFStub(t)
stub.dataForPath = func(_ string, _ map[string]any) any {
if tt.action == "list" {
return []any{}
}
return map[string]any{}
}
args := append([]string{"monit", "folder-" + tt.action}, tt.args...)
if _, err := execCommand(args...); err != nil {
t.Fatal(err)
}
if stub.lastPath != "/monit/folder/"+tt.action {
t.Errorf("path = %q", stub.lastPath)
}
if tt.body != nil && !reflect.DeepEqual(stub.lastBody, tt.body) {
t.Errorf("body = %#v, want %#v", stub.lastBody, tt.body)
}
})
}
}

func TestFolderMoveRequiresDestination(t *testing.T) {
saveAndResetGlobals(t)
stub := newGFStub(t)
_, err := execCommand("monit", "folder-move", "--id", "12")
if err == nil || !strings.Contains(err.Error(), "dest-parent-id") {
t.Fatalf("expected missing destination error, got %v", err)
}
if stub.lastPath != "" {
t.Fatalf("unexpected request to %q", stub.lastPath)
}
}
5 changes: 5 additions & 0 deletions internal/cli/zz_generated_manifest.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion internal/cli/zz_generated_response_help.go

Large diffs are not rendered by default.

Loading
Loading