Files
lazysecrets/internal/clipboard/clipboard_test.go
T
kebandClaude Opus 5.5 cbb155b498
Release / Build and publish (push) Successful in 22s
Hello world 👋
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-12 08:48:23 +02:00

34 lines
707 B
Go

package clipboard
import "testing"
func fakeNative() (*Clipboard, *string) {
var board string
return &Clipboard{
native: true,
read: func() (string, error) { return board, nil },
write: func(s string) error { board = s; return nil },
}, &board
}
func TestClearOnlyIfUnchanged(t *testing.T) {
c, board := fakeNative()
c.Write("secret")()
if *board != "secret" {
t.Fatalf("board = %q", *board)
}
fp := Fingerprint("secret")
*board = "something the user copied later"
c.Clear(fp)()
if *board != "something the user copied later" {
t.Error("cleared text the user copied afterwards")
}
*board = "secret"
c.Clear(fp)()
if *board != "" {
t.Errorf("not cleared: %q", *board)
}
}