|
430 | 430 |
|
431 | 431 | (deftest matching-path-scoped-rules-test |
432 | 432 | (testing "returns every matching path-scoped rule with match details" |
433 | | - (with-redefs [f.rules/path-scoped-rules (constantly [{:id "/workspace-a/.eca/rules/format.md" |
| 433 | + (with-redefs [f.rules/path-scoped-rules (constantly [{:id (h/file-path "/workspace-a/.eca/rules/format.md") |
434 | 434 | :name "format.md" |
435 | 435 | :scope :project |
436 | 436 | :workspace-root (h/file-path "/workspace-a") |
437 | 437 | :paths ["src/**.clj"]} |
438 | | - {:id "/workspace-a/.eca/rules/notes.md" |
| 438 | + {:id (h/file-path "/workspace-a/.eca/rules/notes.md") |
439 | 439 | :name "notes.md" |
440 | 440 | :scope :project |
441 | 441 | :workspace-root (h/file-path "/workspace-a") |
|
563 | 563 | (fs/create-dirs (fs/parent target-file)) |
564 | 564 | (spit rule-file "---\nagent: code\nmodel: \"openai/.*\"\npaths: \"src/**/*.clj\"\nenforce:\n - read\n - modify\n---\n\nUse project Clojure style.") |
565 | 565 | (spit target-file "(ns foo)") |
566 | | - (let [workspace-root (shared/normalize-path tmp-dir) |
567 | | - roots [{:uri (shared/filename->uri (str tmp-dir))}] |
568 | | - rules (f.rules/path-scoped-rules {} roots "code" "openai/gpt-5.2") |
569 | | - rule (first rules)] |
570 | | - (is (= 1 (count rules))) |
571 | | - (is (match? {:name "clojure.md" |
572 | | - :scope :project |
573 | | - :workspace-root workspace-root |
574 | | - :content "Use project Clojure style." |
575 | | - :agents ["code"] |
576 | | - :models ["openai/.*"] |
577 | | - :paths ["src/**/*.clj"] |
578 | | - :enforce ["read" "modify"]} |
579 | | - rule)) |
580 | | - (is (match? {:match? true |
581 | | - :reason nil |
582 | | - :workspace-root workspace-root |
583 | | - :relative-path (str (fs/path "src" "nested" "foo.clj")) |
584 | | - :matched-pattern "src/**/*.clj"} |
585 | | - (f.rules/match-path-scoped-rule rule roots (str target-file))))) |
| 566 | + (with-redefs [config/get-env (constantly (str (fs/path tmp-dir "no-global-config")))] |
| 567 | + (let [workspace-root (shared/normalize-path tmp-dir) |
| 568 | + roots [{:uri (shared/filename->uri (str tmp-dir))}] |
| 569 | + rules (f.rules/path-scoped-rules {} roots "code" "openai/gpt-5.2") |
| 570 | + rule (first rules)] |
| 571 | + (is (= 1 (count rules))) |
| 572 | + (is (match? {:name "clojure.md" |
| 573 | + :scope :project |
| 574 | + :workspace-root workspace-root |
| 575 | + :content "Use project Clojure style." |
| 576 | + :agents ["code"] |
| 577 | + :models ["openai/.*"] |
| 578 | + :paths ["src/**/*.clj"] |
| 579 | + :enforce ["read" "modify"]} |
| 580 | + rule)) |
| 581 | + (is (match? {:match? true |
| 582 | + :reason nil |
| 583 | + :workspace-root workspace-root |
| 584 | + :relative-path (str (fs/path "src" "nested" "foo.clj")) |
| 585 | + :matched-pattern "src/**/*.clj"} |
| 586 | + (f.rules/match-path-scoped-rule rule roots (str target-file)))))) |
586 | 587 | (finally |
587 | 588 | (fs/delete-tree tmp-dir)))))) |
588 | 589 |
|
|
0 commit comments