mirror of
https://github.com/gopasspw/gopass.git
synced 2026-10-03 13:57:32 +02:00
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>
61 lines
1.3 KiB
Go
61 lines
1.3 KiB
Go
package tests
|
|
|
|
import (
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestCopy(t *testing.T) {
|
|
ts := newTester(t)
|
|
defer ts.teardown()
|
|
|
|
t.Run("copy w/ empty store", func(t *testing.T) {
|
|
_, err := ts.run("copy")
|
|
require.Error(t, err)
|
|
})
|
|
|
|
ts.initStore()
|
|
|
|
t.Run("copy usage", func(t *testing.T) {
|
|
out, err := ts.run("copy")
|
|
require.Error(t, err)
|
|
assert.Equal(t, "Usage: "+filepath.Base(ts.Binary)+" cp <FROM> <TO>\n", out)
|
|
})
|
|
|
|
t.Run("copy w/o destination", func(t *testing.T) {
|
|
out, err := ts.run("copy foo")
|
|
require.Error(t, err)
|
|
assert.Equal(t, "Usage: "+filepath.Base(ts.Binary)+" cp <FROM> <TO>\n", out)
|
|
})
|
|
|
|
t.Run("copy non existing source", func(t *testing.T) {
|
|
out, err := ts.run("copy foo bar")
|
|
require.Error(t, err)
|
|
assert.Equal(t, "foo does not exist\n", out)
|
|
})
|
|
|
|
ts.initSecrets("")
|
|
|
|
t.Run("recursive copy", func(t *testing.T) {
|
|
_, err := ts.run("copy foo/ bar")
|
|
require.NoError(t, err)
|
|
})
|
|
|
|
t.Run("copy existing secret to non-existing destination", func(t *testing.T) {
|
|
out, err := ts.run("copy foo/bar foo/baz")
|
|
require.NoError(t, err)
|
|
assert.Empty(t, out)
|
|
|
|
orig, err := ts.run("show -u foo/bar")
|
|
require.NoError(t, err)
|
|
|
|
cp, err := ts.run("show -u foo/baz")
|
|
require.NoError(t, err)
|
|
|
|
assert.Equal(t, orig, cp)
|
|
})
|
|
}
|