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>
29 lines
636 B
Go
29 lines
636 B
Go
package termio
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/gopasspw/gopass/internal/config"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestPassPromptFunc(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
ctx := config.NewContextInMemory()
|
|
|
|
assert.False(t, HasPassPromptFunc(ctx))
|
|
assert.NotNil(t, GetPassPromptFunc(ctx))
|
|
|
|
ctx = WithPassPromptFunc(ctx, func(context.Context, string) (string, error) {
|
|
return "test", nil
|
|
})
|
|
assert.True(t, HasPassPromptFunc(ctx))
|
|
assert.NotNil(t, GetPassPromptFunc(ctx))
|
|
sv, err := GetPassPromptFunc(ctx)(ctx, "")
|
|
require.NoError(t, err)
|
|
assert.Equal(t, "test", sv)
|
|
}
|