mirror of
https://github.com/gopasspw/gopass.git
synced 2026-02-01 17:37:29 +00:00
This commit contains the initial draft of the gopass API. Design and implementation of the API are work in progress - even after this PR has been merged. Feedback welcome but please use with caution. Expect breaking changes to the API. Especially once we redesign the secrets implementation. Fixes #1379 RELEASE_NOTES=[ENHANCEMENT] Add gopass API (unstable) Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>
43 lines
846 B
Go
43 lines
846 B
Go
package action
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/gopasspw/gopass/internal/gptest"
|
|
"github.com/gopasspw/gopass/internal/out"
|
|
"github.com/gopasspw/gopass/pkg/ctxutil"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestSync(t *testing.T) {
|
|
u := gptest.NewUnitTester(t)
|
|
defer u.Remove()
|
|
|
|
buf := &bytes.Buffer{}
|
|
out.Stdout = buf
|
|
out.Stderr = buf
|
|
defer func() {
|
|
out.Stdout = os.Stdout
|
|
out.Stderr = os.Stderr
|
|
}()
|
|
|
|
ctx := context.Background()
|
|
ctx = ctxutil.WithAlwaysYes(ctx, true)
|
|
act, err := newMock(ctx, u)
|
|
require.NoError(t, err)
|
|
require.NotNil(t, act)
|
|
|
|
// default
|
|
assert.NoError(t, act.Sync(gptest.CliCtx(ctx, t)))
|
|
buf.Reset()
|
|
|
|
// sync --store=root
|
|
assert.NoError(t, act.Sync(gptest.CliCtxWithFlags(ctx, t, map[string]string{"store": "root"})))
|
|
buf.Reset()
|
|
}
|