mirror of
https://github.com/gopasspw/gopass.git
synced 2025-12-08 19:24:54 +00:00
* [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>
38 lines
864 B
Go
38 lines
864 B
Go
package backend
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/gopasspw/gopass/internal/config"
|
|
"github.com/gopasspw/gopass/pkg/ctxutil"
|
|
"github.com/gopasspw/gopass/pkg/debug"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestDetectStorage(t *testing.T) {
|
|
ctx := config.NewContextInMemory()
|
|
|
|
td := t.TempDir()
|
|
|
|
// all tests involving age should set GOPASS_HOMEDIR
|
|
t.Setenv("GOPASS_HOMEDIR", td)
|
|
ctx = ctxutil.WithPasswordCallback(ctx, func(_ string, _ bool) ([]byte, error) {
|
|
debug.Log("static test password callback")
|
|
|
|
return []byte("gopass"), nil
|
|
})
|
|
|
|
fsDir := filepath.Join(td, "fs")
|
|
require.NoError(t, os.MkdirAll(fsDir, 0o700))
|
|
|
|
t.Run("detect fs", func(t *testing.T) {
|
|
r, err := DetectStorage(ctx, fsDir)
|
|
require.NoError(t, err)
|
|
assert.NotNil(t, r)
|
|
assert.Equal(t, "fs", r.Name())
|
|
})
|
|
}
|