package access import ( "testing" "git.entityseven.com/rilaxik/pllist/internal/service" ) func TestCommandArgument(t *testing.T) { tests := []struct { name string text string want string }{ {name: "no argument", text: "/allow", want: ""}, {name: "username", text: "/allow @alice_1", want: "@alice_1"}, {name: "numeric id", text: "/kick 12345", want: "12345"}, {name: "command with bot suffix", text: "/allow@pllist_bot alice_1", want: "alice_1"}, {name: "extra words", text: "/allow alice_1 extra", want: "alice_1 extra"}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { if got := commandArgument(tt.text); got != tt.want { t.Fatalf("commandArgument(%q) = %q, want %q", tt.text, got, tt.want) } }) } } func TestTargetLabel(t *testing.T) { if got := targetLabel(service.GrantTarget{Username: "alice_1"}); got != "@alice_1" { t.Fatalf("targetLabel(username) = %q, want @alice_1", got) } if got := targetLabel(service.GrantTarget{TelegramID: 12345}); got != "12345" { t.Fatalf("targetLabel(id) = %q, want 12345", got) } }