package cryptsetup import ( "os" "path/filepath" "testing" ) func TestMapperName(t *testing.T) { tests := []struct { input string want string }{ {"/dev/sda1", "arca-sda1"}, {"/dev/nvme0n1p2", "arca-nvme0n1p2"}, {"/dev/dm-0", "arca-dm-0"}, {"sda1", "arca-sda1"}, } for _, tt := range tests { got := MapperName(tt.input) if got != tt.want { t.Errorf("MapperName(%q) = %q, want %q", tt.input, got, tt.want) } } } func TestHasTokenPlugins_WithPlugins(t *testing.T) { tmp := t.TempDir() os.WriteFile(filepath.Join(tmp, "libcryptsetup-token-systemd-fido2.so"), []byte("fake"), 0o644) if !hasTokenPlugins(tmp) { t.Error("hasTokenPlugins returned false for dir with plugin") } } func TestHasTokenPlugins_EmptyDir(t *testing.T) { tmp := t.TempDir() if hasTokenPlugins(tmp) { t.Error("hasTokenPlugins returned true for empty dir") } } func TestHasTokenPlugins_NonexistentDir(t *testing.T) { if hasTokenPlugins("/nonexistent/path") { t.Error("hasTokenPlugins returned true for nonexistent dir") } }