Files
Dominik Schulz 7c63ba09b7 chore(deps): migrate from urfave/cli v2 to v3 (#3428)
Migrate the entire codebase from github.com/urfave/cli/v2 to
github.com/urfave/cli/v3 (v3.9.0).

Key breaking changes addressed:
- cli.App removed, replaced by *cli.Command
- ActionFunc signature: func(*Context) error -> func(context.Context, *Command) error
- BeforeFunc signature: func(*Context) error -> func(context.Context, *Command) (context.Context, error)
- app.RunContext -> app.Run
- app.EnableBashCompletion -> app.EnableShellCompletion
- Subcommands field renamed to Commands
- EnvVars on flags -> Sources: cli.EnvVars(...)
- cli.NewContext removed; test helpers updated to use cmd.Run() pattern
- cli.Flag interface updated (Apply removed, Get/PreParse/PostParse/Set added)
- VersionPrinter type changed to func(*Command)

Also updates .capabilities.json baseline to reflect new cli/v3 call paths.

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>
2026-05-16 18:13:19 +02:00

64 lines
1.6 KiB
Go

package tests
import (
"path/filepath"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestMove(t *testing.T) {
ts := newTester(t)
defer ts.teardown()
t.Run("move before init", func(t *testing.T) {
_, err := ts.run("move")
require.Error(t, err)
})
// init store so it does exist, but empty so far
ts.initStore()
t.Run("move w/o args", func(t *testing.T) {
out, err := ts.run("move")
require.Error(t, err)
assert.Equal(t, "Usage: "+filepath.Base(ts.Binary)+" mv old-path new-path\n", out)
})
t.Run("move w/o destination", func(t *testing.T) {
out, err := ts.run("move foo")
require.Error(t, err)
assert.Equal(t, "Usage: "+filepath.Base(ts.Binary)+" mv old-path new-path\n", out)
})
t.Run("move non existing source", func(t *testing.T) {
out, err := ts.run("move foo bar")
require.Error(t, err)
assert.Equal(t, "source foo does not exist in source store : entry is not in the password store\n", out)
})
// populate store with secrets
ts.initSecrets("")
t.Run("move a secret", func(t *testing.T) {
_, err := ts.run("move foo bar")
require.NoError(t, err)
})
t.Run("move existing secret from non-existing destination", func(t *testing.T) {
out, _ := ts.run("move foo/bar foo/baz")
assert.Equal(t, "source foo/bar does not exist in source store : entry is not in the password store\n", out)
})
t.Run("show source secret", func(t *testing.T) {
_, err := ts.run("show -u bar/bar")
require.NoError(t, err)
})
t.Run("show secret", func(t *testing.T) {
_, err := ts.run("show -u baz")
require.NoError(t, err)
})
}