Initial import of LogDarioSeq baseline
Establishes version control for the personal Logseq DB fork before starting the server-client architecture migration and domain features described in docs/agent-guide and the approved implementation plan. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
54
cli-e2e/test/logseq/cli/e2e/shell_test.clj
Normal file
54
cli-e2e/test/logseq/cli/e2e/shell_test.clj
Normal file
@@ -0,0 +1,54 @@
|
||||
(ns logseq.cli.e2e.shell-test
|
||||
(:require [babashka.process :as process]
|
||||
[clojure.test :refer [deftest is testing]]
|
||||
[logseq.cli.e2e.shell :as shell]))
|
||||
|
||||
(deftest preserves-the-exact-command-string
|
||||
(let [captured (atom nil)
|
||||
command "node static/logseq-cli.js --graph 'Graph With Space' --help"
|
||||
result (shell/run! {:cmd command
|
||||
:dir "/repo"
|
||||
:executor (fn [cmd opts]
|
||||
(reset! captured {:cmd cmd
|
||||
:opts opts})
|
||||
{:exit 0
|
||||
:out "ok"
|
||||
:err ""})})]
|
||||
(is (= command (:cmd result)))
|
||||
(is (= command (:cmd @captured)))
|
||||
(is (= "/repo" (get-in @captured [:opts :dir])))))
|
||||
|
||||
(deftest shell-failures-include-command-context
|
||||
(let [command "node static/logseq-cli.js completion fish"]
|
||||
(try
|
||||
(shell/run! {:cmd command
|
||||
:executor (fn [_ _]
|
||||
{:exit 2
|
||||
:out ""
|
||||
:err "unsupported shell"})})
|
||||
(is false "Expected shell/run! to throw")
|
||||
(catch clojure.lang.ExceptionInfo ex
|
||||
(is (= command (:cmd (ex-data ex))))
|
||||
(is (= 2 (:exit (ex-data ex))))
|
||||
(is (= "unsupported shell" (:err (ex-data ex))))))))
|
||||
|
||||
(deftest allow-failure-returns-result-without-throwing
|
||||
(let [command "node static/logseq-cli.js graph info --graph missing"
|
||||
result (shell/run! {:cmd command
|
||||
:throw? false
|
||||
:executor (fn [_ _]
|
||||
{:exit 1
|
||||
:out "failed"
|
||||
:err "missing"})})]
|
||||
(is (= command (:cmd result)))
|
||||
(is (= 1 (:exit result)))
|
||||
(is (= "failed" (:out result)))
|
||||
(is (= "missing" (:err result)))))
|
||||
|
||||
(deftest default-executor-uses-resolvable-shell-command
|
||||
(let [captured (atom nil)]
|
||||
(with-redefs [process/process (fn [_opts & args]
|
||||
(reset! captured args)
|
||||
(future {:exit 0}))]
|
||||
(shell/run! {:cmd "echo ok"}))
|
||||
(is (= ["bash" "-c" "echo ok"] @captured))))
|
||||
Reference in New Issue
Block a user