forked from gopasspw/gopass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
move_test.go
40 lines (33 loc) · 840 Bytes
/
move_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package action
import (
"bytes"
"context"
"os"
"testing"
"github.com/gopasspw/gopass/internal/out"
"github.com/gopasspw/gopass/pkg/ctxutil"
"github.com/gopasspw/gopass/tests/gptest"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestMove(t *testing.T) {
u := gptest.NewUnitTester(t)
ctx := context.Background()
ctx = ctxutil.WithAlwaysYes(ctx, true)
ctx = ctxutil.WithInteractive(ctx, false)
act, err := newMock(ctx, u.StoreDir(""))
require.NoError(t, err)
require.NotNil(t, act)
ctx = act.cfg.WithConfig(ctx)
buf := &bytes.Buffer{}
out.Stdout = buf
out.Stderr = buf
defer func() {
out.Stdout = os.Stdout
out.Stderr = os.Stderr
}()
t.Run("move foo to bar", func(t *testing.T) {
defer buf.Reset()
assert.NoError(t, act.Move(gptest.CliCtx(ctx, t, "foo", "bar")))
})
}