TUTORIAL 08 · INTERMEDIATE

Testing a RAIQL Application

Generate contract, security, password and PostgreSQL tests directly from the ServiceDesk requirements.

RAIQL 1.020 minProject: ServiceDesk
By the end of this tutorial
  • Enable generated tests
  • Run raiql test
  • Understand contract and security test groups
  • Use testing as a release gate

Make tests part of the requirements

GENERATE TESTS is explicit intent. Once present, the generator emits tests based on the compiled entities, permissions, authentication and persistence model.

app.raiql
CREATE APPLICATION "RAIQL ServiceDesk";
TYPE WEB;

USE STACK
  FRONTEND NEXTJS,
  BACKEND NEXTJS,
  DATABASE POSTGRESQL;

CREATE TENANT ENTITY Tenant;
CREATE USER ENTITY User;

CREATE ENTITY Ticket (
  id UUID PRIMARY,
  title STRING REQUIRED,
  description STRING,
  status STRING REQUIRED,
  priority STRING REQUIRED,
  ownerId UUID REQUIRED,
  tenantId UUID REQUIRED
);

CREATE CRUD Tenant;
CREATE API Tenant;
CREATE CRUD Ticket;
CREATE API Ticket;

ADD AUTHENTICATION EMAIL_PASSWORD, JWT;
ADD ROLE ADMIN, AGENT, USER;
DEFAULT ROLE USER;

RELATE Ticket.ownerId TO User.id;
RELATE Ticket.tenantId TO Tenant.id;
OWN Ticket BY ownerId;
TENANT Ticket BY tenantId;

ALLOW ADMIN CREATE Ticket, READ Ticket, UPDATE Ticket, DELETE Ticket, CREATE Tenant, READ Tenant, UPDATE Tenant, DELETE Tenant;
ALLOW AGENT READ Ticket, UPDATE Ticket;
ALLOW USER CREATE OWN Ticket, READ OWN Ticket, UPDATE OWN Ticket;

ENVIRONMENT development, staging, production;
SECRET DATABASE_URL;
SECRET RAIQL_JWT_SECRET;

EVENT TicketCreated FROM Ticket;
JOB ProcessTicket ON TicketCreated;

GENERATE OPENAPI;
GENERATE SDK TYPESCRIPT;
GENERATE TESTS;

BUILD;
DEPLOY DOCKER;

Run the complete RAIQL test workflow

terminal
raiql validate
raiql test --env development

Run groups directly

terminal
cd generated
npm run test:contracts
npm run test:security
npm run test:db

What the generated suite verifies

  • The generated IR matches the declared application contract
  • Role and OWN permissions match the policy matrix
  • Password hashing accepts valid credentials and rejects invalid ones
  • PostgreSQL is reachable and generated tables exist

CI gate

Because raiql test returns a process exit code, it can be used directly in Jenkins, GitHub Actions or another CI system.

pipeline
raiql validate
raiql lock
raiql audit
raiql test --env development
raiql build --env production