Files
bookhoard/bruno/collections/Test Collection Rules - Author Contains.bru
T
john-okeefe 26070e4000 Refactor: rename baseUrl to base_url in .bru files
Update configuration key naming convention to use snake_case
consistently.
Applies changes recursively across all subdirectories.
2026-02-08 21:26:31 -05:00

62 lines
1.4 KiB
Plaintext

meta {
name: Test Collection Rules - Author Contains
type: http
seq: 2
}
post {
url: {{base_url}}/api/collections/test-rules
body: json
auth: inherit
}
headers {
Content-Type: application/json
Authorization: Bearer {{authToken}}
}
body:json {
{
"rules": [
{
"field": "author",
"operator": "contains",
"value": "Asimov"
}
]
}
}
script:post-response {
function onResponse(res) {
if (res.getStatus() === 200) {
tests['Author search successful'] = true;
const body = res.getBody();
tests['Has matches array'] = Array.isArray(body.matches);
tests['Found books by Asimov'] = body.matches.length > 0;
} else {
tests['Author search failed'] = false;
}
}
onResponse(res);
}
settings {
encodeUrl: true
timeout: 0
}
docs {
## Test Collection Rules - Author Contains
Tests the "contains" operator on the author field to find books by a specific author (partial match).
**Example Use Case:** Finding all books by an author whose name contains "Asimov" (e.g., "Isaac Asimov").
**Operator:** `contains` - Matches if the field contains the specified value as a substring (case-insensitive typically).
**Expected Result:** Returns all books where the author field contains "Asimov".
**Purpose:** Demonstrates text-based partial matching for author searches, useful when you don't need the exact author name or want to find books by authors with similar names.
}