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>
55 lines
1.1 KiB
Go
55 lines
1.1 KiB
Go
package backend
|
|
|
|
import (
|
|
"bytes"
|
|
"os"
|
|
"os/exec"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/gopasspw/gopass/internal/config"
|
|
"github.com/gopasspw/gopass/internal/out"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestClone(t *testing.T) {
|
|
ctx := config.NewContextInMemory()
|
|
|
|
td := t.TempDir()
|
|
|
|
repo := filepath.Join(td, "repo")
|
|
require.NoError(t, os.MkdirAll(repo, 0o700))
|
|
|
|
store := filepath.Join(td, "store")
|
|
require.NoError(t, os.MkdirAll(store, 0o700))
|
|
|
|
cmd := exec.Command("git", "init", repo)
|
|
require.NoError(t, cmd.Run())
|
|
|
|
r, err := Clone(ctx, GitFS, repo, store)
|
|
require.NoError(t, err)
|
|
assert.NotNil(t, r)
|
|
}
|
|
|
|
func TestInitRCS(t *testing.T) {
|
|
ctx := config.NewContextInMemory()
|
|
|
|
td := t.TempDir()
|
|
|
|
buf := &bytes.Buffer{}
|
|
out.Stdout = buf
|
|
out.Stderr = buf
|
|
defer func() {
|
|
out.Stdout = os.Stdout
|
|
out.Stderr = os.Stderr
|
|
}()
|
|
|
|
gitDir := filepath.Join(td, "git")
|
|
require.NoError(t, os.MkdirAll(filepath.Join(gitDir, ".git"), 0o700))
|
|
|
|
r, err := InitStorage(ctx, GitFS, gitDir)
|
|
require.NoError(t, err)
|
|
assert.NotNil(t, r)
|
|
}
|