---
id: TASK-10.3
title: >-
  Add API tests for compile_commands symlink edge cases and default profile
  resolution
status: Done
assignee:
  - '@codex'
created_date: '2026-02-04 11:47'
updated_date: '2026-02-04 11:57'
labels: []
dependencies: []
references:
  - spec/zync_spec.lua
  - lua/zync/api.lua
parent_task_id: TASK-10
---

## Description

<!-- SECTION:DESCRIPTION:BEGIN -->
Extend zync top-level API tests to cover default profile resolution paths used by compile_commands symlink creation and edge cases around existing link/file handling.
<!-- SECTION:DESCRIPTION:END -->

## Acceptance Criteria
<!-- AC:BEGIN -->
- [x] #1 Tests cover default profile resolution when `default_profile` is absent and `profile_order` should be used (assert symlink points to the first declared profile, not alphabetical).
- [x] #2 Tests cover compile_commands link handling when `build/compile_commands.json` exists as a regular file (ensure it is replaced with a link to the selected profile’s compile_commands.json).
- [x] #3 Tests cover behavior when `project_dir` is missing and current working directory should be used for compile_commands link creation.
- [x] #4 Tests validate behavior outcomes, not just code paths.
<!-- AC:END -->

## Implementation Plan

<!-- SECTION:PLAN:BEGIN -->
1. Add a zync API spec that uses `profiles` without `default_profile` and with a declaration order that differs from alphabetical; verify the `build/compile_commands.json` symlink points to the first declared profile.
2. Add a spec where `build/compile_commands.json` exists as a regular file; run `z.api.run()` and assert it gets replaced with a symlink to the selected profile’s compile_commands.json.
3. Add a spec where `project_dir` is absent (or empty) and ensure compile_commands symlink creation uses the current working directory.
<!-- SECTION:PLAN:END -->

## Implementation Notes

<!-- SECTION:NOTES:BEGIN -->
Added API specs for compile_commands symlink when default_profile missing (declaration order), replacing existing file with symlink, and using cwd when project_dir missing.

Ran `busted spec/zync_spec.lua` (22/0/0/0).
<!-- SECTION:NOTES:END -->
