This commit is contained in:
2026-09-09 12:30:40 +07:00
parent 94fc85f074
commit 4feece62c8
21 changed files with 854 additions and 85 deletions
+30
View File
@@ -0,0 +1,30 @@
package app
import (
"context"
"testing"
"evening_detective_server/proto"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
func TestDownloadTeamQRAccess(t *testing.T) {
s := &server{}
for _, tc := range []struct {
ctx context.Context
id int32
want codes.Code
}{
{context.Background(), 1, codes.Unauthenticated},
{ctxWithClaims(), 1, codes.PermissionDenied},
{ctxWithClaims("organizer"), 0, codes.InvalidArgument},
{ctxWithClaims("author"), -1, codes.InvalidArgument},
{ctxWithClaims("admin"), 0, codes.InvalidArgument},
} {
_, err := s.DownloadTeamQR(tc.ctx, &proto.GetGameReq{Id: tc.id})
if status.Code(err) != tc.want {
t.Errorf("code = %v, want %v", status.Code(err), tc.want)
}
}
}