---
id: TASK-10.1
title: Add configurator tests for profile order parsing and profile validation errors
status: Done
assignee:
  - '@codex'
created_date: '2026-02-04 11:47'
updated_date: '2026-02-04 11:49'
labels: []
dependencies: []
references:
  - spec/api_spec/configurator_spec.lua
  - spec/fixtures/configurator_fix.lua
  - lua/zync/api/configurator.lua
parent_task_id: TASK-10
---

## Description

<!-- SECTION:DESCRIPTION:BEGIN -->
Extend configurator specs to exercise profile order parsing (including comments/quoted keys/bracket keys), default selection behavior, and validation error branches (profiles not table, no profiles defined, non-table profile).
<!-- SECTION:DESCRIPTION:END -->

## Acceptance Criteria
<!-- AC:BEGIN -->
- [x] #1 Tests cover profile order parsing from zconf.lua with comments/strings/bracketed keys and confirm `profile_order` and selected profile follow the declared order.
- [x] #2 Tests cover error cases in `apply_profile`: profiles not a table, profiles table empty, and profile entry not a table (assert error messages).
- [x] #3 Tests cover build-dir detection when invoked from `build/<profile>` and ensure `build_dir`/`project_dir` are set appropriately.
- [x] #4 New tests are meaningful (assert behavior and config outcomes, not just line hits).
<!-- AC:END -->

## Implementation Plan

<!-- SECTION:PLAN:BEGIN -->
1. Add a configurator spec that builds a `zconf.lua` with mixed profile key styles (identifier keys, quoted keys, bracketed string keys), plus comments and strings, then assert `profile_order` preserves declaration order and the selected profile defaults to the first declared entry.
2. Add configurator specs for error branches in `apply_profile`: `profiles` not a table, profiles table empty, and profile entry not a table; assert specific error messages.
3. Add a configurator spec for `build/<profile>` invocation: run `init_conf` from `build/<profile>` and assert `project_dir`, `build_dir`, and `profile` are set correctly.
<!-- SECTION:PLAN:END -->

## Implementation Notes

<!-- SECTION:NOTES:BEGIN -->
Added configurator specs for profile order parsing with mixed key styles, apply_profile error branches (profiles not table, empty profiles, non-table profile), and build/<profile> path resolution.

Ran `busted spec/api_spec/configurator_spec.lua` (9/0/0/0).
<!-- SECTION:NOTES:END -->
