|
24 | 24 | import org.junit.jupiter.api.Test; |
25 | 25 |
|
26 | 26 | import io.github.easy4j.comfy.cli.ComfyCli; |
| 27 | +import com.fasterxml.jackson.databind.JsonNode; |
27 | 28 | import io.github.easy4j.comfy.cli.ComfyCliExecutor; |
28 | 29 |
|
29 | 30 | /** |
@@ -77,18 +78,14 @@ void shouldRaiseWhenGenerateJsonPrintsNonJson() { |
77 | 78 | } |
78 | 79 |
|
79 | 80 | @Test |
80 | | - void shouldParseGenerateJsonOutput() { |
81 | | - // /bin/sh built-ins let us emit a real JSON document for --json runs. |
| 81 | + void shouldParseGenerateJsonOutput() throws Exception { |
82 | 82 | ComfyClientConfig config = echoConfig(); |
83 | | - config.setLocalExecutable("/bin/sh"); |
| 83 | + config.setLocalExecutable( |
| 84 | + java.nio.file.Paths.get("src", "test", "resources", "comfy-json.sh").toAbsolutePath().toString()); |
84 | 85 | try (ComfyClient client = new ComfyClient(config)) { |
85 | | - ComfyCli.GenerateOptions options = new ComfyCli.GenerateOptions() |
86 | | - .prompt("x").json(true) |
87 | | - .download("/nonexistent-dir-xyz/out.png"); |
88 | | - // echo 不可用,改为直接断言失败路径之外的成功解析: |
89 | | - // 用 sh 打印固定 JSON 并跳过 generateJson(其内部先执行后解析), |
90 | | - // 这里以 mapper 直测——保持端到端语义由 MCP/CLI 契约测试覆盖。 |
91 | | - assertTrue(client.version().getExitCode() == 0); |
| 86 | + JsonNode json = client.generateJson("flux-pro", |
| 87 | + new ComfyCli.GenerateOptions().prompt("hi").json(true)); |
| 88 | + assertEquals("https://example/asset.png", json.path("data").get(0).path("url").asText()); |
92 | 89 | } |
93 | 90 | } |
94 | 91 |
|
|
0 commit comments