← Kembali ke Dokumentasi
Contoh dokumentasi backend

create-antrian.bru

docs/03-api/bruno/antrian/create-antrian.bru

Contoh isi file untuk sistem antrian. Sesuaikan dengan implementasi proyek Anda.

meta {
  name: Create Antrian
  type: http
  seq: 1
}

post {
  url: {{base_url}}/api/v1/antrian
  body: json
  auth: bearer
}

auth:bearer {
  token: {{access_token}}
}

headers {
  Content-Type: application/json
  Accept: application/json
  Idempotency-Key: {{idempotency_key}}
}

body:json {
  {
    "service_code": "GENERAL"
  }
}

script:post-response {
  bru.setVar("antrian_id", "");
  if (res.getStatus() === 201) {
    bru.setVar("antrian_id", res.getBody().data.antrian_id);
  }
}

tests {
  test("Antrian dibuat dengan status waiting", function () {
    const body = res.getBody();
    expect(res.getStatus()).to.equal(201);
    expect(body.success).to.equal(true);
    expect(body.message).to.be.a("string");
    expect(body.data.antrian_id).to.be.a("string").and.not.empty;
    expect(body.data.status).to.equal("waiting");
    expect(body.meta.request_id).to.be.a("string");
  });
}

docs {
  Contoh request yang mengubah data. Jalankan Login lebih dahulu.
  Gunakan key baru untuk pendaftaran baru; retry memakai key dan payload yang sama.
}