mirror of
https://github.com/gopasspw/gopass.git
synced 2026-05-30 11:18:48 +02:00
7281ca8ab4
* [chore] Migrate to golangci-lint v2 Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org> * [chore] Fix more lint issues Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org> * [chore] Fix more lint issue Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org> * [chore] Fix more lint issues Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org> * [chore] Add more package comments. Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org> * [chore] Fix golangci-lint config and the remaining checks Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org> * [fix] Use Go 1.24 Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org> * [fix] Fix container builds Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org> * Fix more failing tests Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org> * Fix test failure Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org> * Fix another len assertion Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org> * Move location tests Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org> * [fix] Fix most remaining lint issues Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org> * [fix] Only run XDG specific tests on linux Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org> * [fix] Attempt to address on source of flaky failures Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org> --------- Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>
70 lines
1.4 KiB
Go
70 lines
1.4 KiB
Go
package action
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/gopasspw/gopass/internal/config"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestWithClip(t *testing.T) {
|
|
ctx := config.NewContextInMemory()
|
|
|
|
if IsClip(ctx) {
|
|
t.Errorf("Should be false")
|
|
}
|
|
|
|
if !IsClip(WithClip(ctx, true)) {
|
|
t.Errorf("Should be true")
|
|
}
|
|
}
|
|
|
|
func TestWithPasswordOnly(t *testing.T) {
|
|
ctx := config.NewContextInMemory()
|
|
|
|
if IsPasswordOnly(ctx) {
|
|
t.Errorf("Should be false")
|
|
}
|
|
|
|
if !IsPasswordOnly(WithPasswordOnly(ctx, true)) {
|
|
t.Errorf("Should be true")
|
|
}
|
|
}
|
|
|
|
func TestWithPrintQR(t *testing.T) {
|
|
ctx := config.NewContextInMemory()
|
|
|
|
assert.False(t, IsPrintQR(ctx))
|
|
assert.True(t, IsPrintQR(WithPrintQR(ctx, true)))
|
|
}
|
|
|
|
func TestWithRevision(t *testing.T) {
|
|
ctx := config.NewContextInMemory()
|
|
|
|
assert.Empty(t, GetRevision(ctx))
|
|
assert.Equal(t, "foo", GetRevision(WithRevision(ctx, "foo")))
|
|
assert.False(t, HasRevision(ctx))
|
|
assert.True(t, HasRevision(WithRevision(ctx, "foo")))
|
|
}
|
|
|
|
func TestWithKey(t *testing.T) {
|
|
ctx := config.NewContextInMemory()
|
|
|
|
assert.Empty(t, GetKey(ctx))
|
|
assert.Equal(t, "foo", GetKey(WithKey(ctx, "foo")))
|
|
}
|
|
|
|
func TestWithOnlyClip(t *testing.T) {
|
|
ctx := config.NewContextInMemory()
|
|
|
|
assert.False(t, IsOnlyClip(ctx))
|
|
assert.True(t, IsOnlyClip(WithOnlyClip(ctx, true)))
|
|
}
|
|
|
|
func TestWithAlsoClip(t *testing.T) {
|
|
ctx := config.NewContextInMemory()
|
|
|
|
assert.False(t, IsAlsoClip(ctx))
|
|
assert.True(t, IsAlsoClip(WithAlsoClip(ctx, true)))
|
|
}
|