From 52b1f8a2d47b3c1ebee5a46f70162d6454b1127c Mon Sep 17 00:00:00 2001 From: Alex Ababii Date: Thu, 10 Sep 2026 11:23:01 +0200 Subject: [PATCH 1/2] document params for thrash bin cli commands --- .../storage-users/pkg/command/trash_bin.go | 6 ++--- .../pkg/command/trash_bin_test.go | 24 +++++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/services/storage-users/pkg/command/trash_bin.go b/services/storage-users/pkg/command/trash_bin.go index dc356c48b2..c43119477a 100644 --- a/services/storage-users/pkg/command/trash_bin.go +++ b/services/storage-users/pkg/command/trash_bin.go @@ -85,7 +85,7 @@ func PurgeExpiredResources(cfg *config.Config) *cobra.Command { func listTrashBinItems(cfg *config.Config) *cobra.Command { listTrashBinItemsCmd := &cobra.Command{ - Use: "list", + Use: "list space", Short: "Print a list of all trash-bin items of a space.", // TODO: n might need to equal 2 not sure. Args: cobra.ExactArgs(1), @@ -143,7 +143,7 @@ func listTrashBinItems(cfg *config.Config) *cobra.Command { func restoreAllTrashBinItems(cfg *config.Config) *cobra.Command { var overwriteOption int restoreAllTrashBinItemsCmd := &cobra.Command{ - Use: "restore-all", + Use: "restore-all space", Short: "Restore all trash-bin items for a space.", // TODO: not sure this could also be 2 Args: cobra.ExactArgs(1), @@ -253,7 +253,7 @@ func restoreAllTrashBinItems(cfg *config.Config) *cobra.Command { func restoreTrashBinItem(cfg *config.Config) *cobra.Command { var overwriteOption int restoreTrashBinItemCmd := &cobra.Command{ - Use: "restore", + Use: "restore space item", Short: "Restore a trash-bin item by ID.", Args: cobra.ExactArgs(2), PreRunE: func(cmd *cobra.Command, args []string) error { diff --git a/services/storage-users/pkg/command/trash_bin_test.go b/services/storage-users/pkg/command/trash_bin_test.go index 26cfd4bc15..aeae663f32 100644 --- a/services/storage-users/pkg/command/trash_bin_test.go +++ b/services/storage-users/pkg/command/trash_bin_test.go @@ -2,8 +2,32 @@ package command import ( "testing" + + "github.com/opencloud-eu/opencloud/services/storage-users/pkg/config" + + "github.com/spf13/cobra" ) +func Test_trashBinCommandUse(t *testing.T) { + cfg := &config.Config{} + tests := []struct { + name string + cmd *cobra.Command + want string + }{ + {"list", listTrashBinItems(cfg), "list space"}, + {"restore-all", restoreAllTrashBinItems(cfg), "restore-all space"}, + {"restore", restoreTrashBinItem(cfg), "restore space item"}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := tt.cmd.Use; got != tt.want { + t.Errorf("Use = %q, want %q", got, tt.want) + } + }) + } +} + func Test_modifyFilename(t *testing.T) { type args struct { filename string From 23cc4c3649a0d1ee27eed184825dd31557121336 Mon Sep 17 00:00:00 2001 From: Alex Ababii Date: Wed, 16 Sep 2026 12:44:26 +0200 Subject: [PATCH 2/2] upd trash bin cli commands flags --- services/storage-users/pkg/command/trash_bin.go | 6 +++--- services/storage-users/pkg/command/trash_bin_test.go | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/services/storage-users/pkg/command/trash_bin.go b/services/storage-users/pkg/command/trash_bin.go index c43119477a..b19122f48f 100644 --- a/services/storage-users/pkg/command/trash_bin.go +++ b/services/storage-users/pkg/command/trash_bin.go @@ -85,7 +85,7 @@ func PurgeExpiredResources(cfg *config.Config) *cobra.Command { func listTrashBinItems(cfg *config.Config) *cobra.Command { listTrashBinItemsCmd := &cobra.Command{ - Use: "list space", + Use: "list ", Short: "Print a list of all trash-bin items of a space.", // TODO: n might need to equal 2 not sure. Args: cobra.ExactArgs(1), @@ -143,7 +143,7 @@ func listTrashBinItems(cfg *config.Config) *cobra.Command { func restoreAllTrashBinItems(cfg *config.Config) *cobra.Command { var overwriteOption int restoreAllTrashBinItemsCmd := &cobra.Command{ - Use: "restore-all space", + Use: "restore-all ", Short: "Restore all trash-bin items for a space.", // TODO: not sure this could also be 2 Args: cobra.ExactArgs(1), @@ -253,7 +253,7 @@ func restoreAllTrashBinItems(cfg *config.Config) *cobra.Command { func restoreTrashBinItem(cfg *config.Config) *cobra.Command { var overwriteOption int restoreTrashBinItemCmd := &cobra.Command{ - Use: "restore space item", + Use: "restore ", Short: "Restore a trash-bin item by ID.", Args: cobra.ExactArgs(2), PreRunE: func(cmd *cobra.Command, args []string) error { diff --git a/services/storage-users/pkg/command/trash_bin_test.go b/services/storage-users/pkg/command/trash_bin_test.go index aeae663f32..5a7e17c446 100644 --- a/services/storage-users/pkg/command/trash_bin_test.go +++ b/services/storage-users/pkg/command/trash_bin_test.go @@ -15,9 +15,9 @@ func Test_trashBinCommandUse(t *testing.T) { cmd *cobra.Command want string }{ - {"list", listTrashBinItems(cfg), "list space"}, - {"restore-all", restoreAllTrashBinItems(cfg), "restore-all space"}, - {"restore", restoreTrashBinItem(cfg), "restore space item"}, + {"list", listTrashBinItems(cfg), "list "}, + {"restore-all", restoreAllTrashBinItems(cfg), "restore-all "}, + {"restore", restoreTrashBinItem(cfg), "restore "}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) {