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>
34 lines
654 B
Go
34 lines
654 B
Go
package cui
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/gopasspw/gopass/internal/config"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
"github.com/urfave/cli/v2"
|
|
)
|
|
|
|
func TestCreateActions(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
ctx := config.NewContextInMemory()
|
|
cas := Actions{
|
|
{
|
|
Name: "foo",
|
|
},
|
|
{
|
|
Name: "bar",
|
|
Fn: func(context.Context, *cli.Context) error {
|
|
return nil
|
|
},
|
|
},
|
|
}
|
|
assert.Equal(t, []string{"foo", "bar"}, cas.Selection())
|
|
require.Error(t, cas.Run(ctx, nil, 0))
|
|
require.NoError(t, cas.Run(ctx, nil, 1))
|
|
require.Error(t, cas.Run(ctx, nil, 2))
|
|
require.Error(t, cas.Run(ctx, nil, 66))
|
|
}
|