Files
bot-pontos/backend/internal/httpapi/middleware_test.go
2026-10-23 22:31:02 -03:00

27 lines
744 B
Go

package httpapi
import (
"testing"
"botpontos/internal/domain"
)
func TestIsRestricted(t *testing.T) {
id := int64(7)
cases := []struct {
name string
account domain.WebAccount
want bool
}{
{"leitura ligada a um usuário", domain.WebAccount{Role: domain.RoleViewer, UserID: &id}, true},
{"leitura sem vínculo", domain.WebAccount{Role: domain.RoleViewer}, false},
{"admin ligado a um usuário", domain.WebAccount{Role: domain.RoleAdmin, UserID: &id}, false},
{"owner ligado a um usuário", domain.WebAccount{Role: domain.RoleOwner, UserID: &id}, false},
}
for _, c := range cases {
if got := isRestricted(c.account); got != c.want {
t.Errorf("%s: isRestricted = %v, esperado %v", c.name, got, c.want)
}
}
}