mirror of
https://github.com/gopasspw/gopass.git
synced 2025-12-08 19:24:54 +00:00
This commit adds yet another config handler for gopass. It is based on the format used by git itself. This has the potential to address a lot of long standing issues, but it also causes a lot of changes to how we handle configuration, so bugs are inevitable. Fixes #1567 Fixes #1764 Fixes #1819 Fixes #1878 Fixes #2387 Fixes #2418 RELEASE_NOTES=[BREAKING] New config format based on git config. Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org> Co-authored-by: Yolan Romailler <AnomalRoil@users.noreply.github.com> address comments Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org> Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>
50 lines
853 B
Go
50 lines
853 B
Go
package gitconfig
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestTrim(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
for _, tc := range [][]string{
|
|
{" a ", "b ", "\tc\n"},
|
|
} {
|
|
trim(tc)
|
|
for _, e := range tc {
|
|
assert.Equal(t, strings.TrimSpace(e), e)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestSplitKey(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
for _, tc := range []struct {
|
|
in string
|
|
section string
|
|
subsection string
|
|
key string
|
|
}{
|
|
{
|
|
in: "url.git@gist.github.com:.pushinsteadof",
|
|
section: "url",
|
|
subsection: "git@gist.github.com:",
|
|
key: "pushinsteadof",
|
|
},
|
|
{
|
|
in: "gc.auto",
|
|
section: "gc",
|
|
key: "auto",
|
|
},
|
|
} {
|
|
sec, sub, key := splitKey(tc.in)
|
|
assert.Equal(t, tc.section, sec, sec)
|
|
assert.Equal(t, tc.subsection, sub, sub)
|
|
assert.Equal(t, tc.key, key, key)
|
|
}
|
|
}
|