mirror of
https://github.com/gopasspw/gopass.git
synced 2026-05-30 11:18:48 +02:00
263b78119b
* [bugfix] Fix writes to global config from tests Fixes #2725 Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org> * Shorten readonly config creation. Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org> * Address review comments Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org> --------- Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>
36 lines
939 B
Go
36 lines
939 B
Go
package root
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/gopasspw/gopass/internal/backend"
|
|
"github.com/gopasspw/gopass/internal/config"
|
|
"github.com/gopasspw/gopass/pkg/ctxutil"
|
|
"github.com/gopasspw/gopass/tests/gptest"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestInit(t *testing.T) {
|
|
u := gptest.NewUnitTester(t)
|
|
|
|
ctx := config.NewContextInMemory()
|
|
ctx = ctxutil.WithAlwaysYes(ctx, true)
|
|
ctx = ctxutil.WithHidden(ctx, true)
|
|
ctx = backend.WithCryptoBackend(ctx, backend.Plain)
|
|
|
|
cfg := config.NewInMemory()
|
|
require.NoError(t, cfg.SetPath(u.StoreDir("rs")))
|
|
rs := New(cfg)
|
|
|
|
inited, err := rs.IsInitialized(ctx)
|
|
require.NoError(t, err)
|
|
assert.False(t, inited)
|
|
require.NoError(t, rs.Init(ctx, "", u.StoreDir("rs"), "0xDEADBEEF"))
|
|
|
|
inited, err = rs.IsInitialized(ctx)
|
|
require.NoError(t, err)
|
|
assert.True(t, inited)
|
|
require.NoError(t, rs.Init(ctx, "rs2", u.StoreDir("rs2"), "0xDEADBEEF"))
|
|
}
|