Files
gopass-mirror/internal/completion/fish/completion_escaping_test.go
Dominik Schulz aea4987ee0 Fix autocompletion issues (#3336)
This is an attempt to fix the different autocopletion issues. Since I
couldn't reproduce most of them, I'm not completely sure if the fixes
are effective.

Fixes #3086
Fixes #3105
Fixes #3285

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>
2026-02-14 21:20:55 +01:00

57 lines
1.0 KiB
Go

package fish
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestEscapePasswordName(t *testing.T) {
t.Parallel()
tests := []struct {
name string
input string
expected string
}{
{
name: "single quote",
input: "password'with'quotes",
expected: "password'\\''with'\\''quotes",
},
{
name: "backslash",
input: "path\\to\\password",
expected: "path\\\\to\\\\password",
},
{
name: "backslash and quote",
input: "test\\with'quote",
expected: "test\\\\with'\\''quote",
},
{
name: "colon",
input: "cloudflare/api-tokens/DNS:Edit/nasvic.top",
expected: "cloudflare/api-tokens/DNS:Edit/nasvic.top",
},
{
name: "no special chars",
input: "simple/password",
expected: "simple/password",
},
{
name: "empty string",
input: "",
expected: "",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
result := escapePasswordName(tt.input)
assert.Equal(t, tt.expected, result)
})
}
}