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) } } }