Skip to content
Open
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
6 changes: 3 additions & 3 deletions services/storage-users/pkg/command/trash_bin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Use: "list space",
Use: "list [space-id]",

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),
Expand Down Expand Up @@ -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",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Use: "restore-all space",
Use: "restore-all [space-id]",

Short: "Restore all trash-bin items for a space.",
// TODO: not sure this could also be 2
Args: cobra.ExactArgs(1),
Expand Down Expand Up @@ -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",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Use: "restore space item",
Use: "restore [space-id] [item-id]",

Short: "Restore a trash-bin item by ID.",
Args: cobra.ExactArgs(2),
PreRunE: func(cmd *cobra.Command, args []string) error {
Expand Down
24 changes: 24 additions & 0 deletions services/storage-users/pkg/command/trash_bin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down