From fb928abb67bd4df99040721ed48c3b42e24b1d08 Mon Sep 17 00:00:00 2001 From: Austin Horstman Date: Tue, 16 Sep 2025 21:43:58 -0500 Subject: [PATCH] tests/claude-code: add path tests for agents/commands Signed-off-by: Austin Horstman --- .../programs/claude-code/agents-path.nix | 14 +++++++ .../programs/claude-code/commands-path.nix | 14 +++++++ .../modules/programs/claude-code/default.nix | 3 ++ .../programs/claude-code/mixed-content.nix | 38 +++++++++++++++++++ .../programs/claude-code/test-agent.md | 8 ++++ .../programs/claude-code/test-command.md | 9 +++++ 6 files changed, 86 insertions(+) create mode 100644 tests/modules/programs/claude-code/agents-path.nix create mode 100644 tests/modules/programs/claude-code/commands-path.nix create mode 100644 tests/modules/programs/claude-code/mixed-content.nix create mode 100644 tests/modules/programs/claude-code/test-agent.md create mode 100644 tests/modules/programs/claude-code/test-command.md diff --git a/tests/modules/programs/claude-code/agents-path.nix b/tests/modules/programs/claude-code/agents-path.nix new file mode 100644 index 00000000..31cd6fec --- /dev/null +++ b/tests/modules/programs/claude-code/agents-path.nix @@ -0,0 +1,14 @@ +{ + programs.claude-code = { + enable = true; + agents = { + test-agent = ./test-agent.md; + }; + }; + + nmt.script = '' + assertFileExists home-files/.claude/agents/test-agent.md + assertFileContent home-files/.claude/agents/test-agent.md \ + ${./test-agent.md} + ''; +} diff --git a/tests/modules/programs/claude-code/commands-path.nix b/tests/modules/programs/claude-code/commands-path.nix new file mode 100644 index 00000000..691da9b8 --- /dev/null +++ b/tests/modules/programs/claude-code/commands-path.nix @@ -0,0 +1,14 @@ +{ + programs.claude-code = { + enable = true; + commands = { + test-command = ./test-command.md; + }; + }; + + nmt.script = '' + assertFileExists home-files/.claude/commands/test-command.md + assertFileContent home-files/.claude/commands/test-command.md \ + ${./test-command.md} + ''; +} diff --git a/tests/modules/programs/claude-code/default.nix b/tests/modules/programs/claude-code/default.nix index f7bf30fb..2e17a6be 100644 --- a/tests/modules/programs/claude-code/default.nix +++ b/tests/modules/programs/claude-code/default.nix @@ -8,4 +8,7 @@ claude-code-agents-dir = ./agents-dir.nix; claude-code-commands-dir = ./commands-dir.nix; claude-code-hooks-dir = ./hooks-dir.nix; + claude-code-agents-path = ./agents-path.nix; + claude-code-commands-path = ./commands-path.nix; + claude-code-mixed-content = ./mixed-content.nix; } diff --git a/tests/modules/programs/claude-code/mixed-content.nix b/tests/modules/programs/claude-code/mixed-content.nix new file mode 100644 index 00000000..b02dfd99 --- /dev/null +++ b/tests/modules/programs/claude-code/mixed-content.nix @@ -0,0 +1,38 @@ +{ + programs.claude-code = { + enable = true; + commands = { + inline-command = '' + --- + allowed-tools: Read + description: Inline command + --- + This command is defined inline. + ''; + path-command = ./test-command.md; + }; + agents = { + inline-agent = '' + --- + name: inline-agent + description: Inline agent + tools: Read + --- + This agent is defined inline. + ''; + path-agent = ./test-agent.md; + }; + }; + + nmt.script = '' + assertFileExists home-files/.claude/commands/inline-command.md + assertFileExists home-files/.claude/commands/path-command.md + assertFileExists home-files/.claude/agents/inline-agent.md + assertFileExists home-files/.claude/agents/path-agent.md + + assertFileContent home-files/.claude/commands/path-command.md \ + ${./test-command.md} + assertFileContent home-files/.claude/agents/path-agent.md \ + ${./test-agent.md} + ''; +} diff --git a/tests/modules/programs/claude-code/test-agent.md b/tests/modules/programs/claude-code/test-agent.md new file mode 100644 index 00000000..4f9da1f3 --- /dev/null +++ b/tests/modules/programs/claude-code/test-agent.md @@ -0,0 +1,8 @@ +--- +name: test-agent +description: Test agent loaded from file path +tools: Read, Write +--- + +This is a test agent loaded from a file path. +Used to verify path support functionality. \ No newline at end of file diff --git a/tests/modules/programs/claude-code/test-command.md b/tests/modules/programs/claude-code/test-command.md new file mode 100644 index 00000000..cc02f072 --- /dev/null +++ b/tests/modules/programs/claude-code/test-command.md @@ -0,0 +1,9 @@ +--- +allowed-tools: Bash, Read +argument-hint: [test-arg] +description: Test command loaded from file path +--- + +This is a test command loaded from a file path. +Used to verify path support functionality. +Usage: /test-command [test-arg] \ No newline at end of file