Restore clj-github.test-helpers/build-spec behavior#40
Conversation
`build-spec` was changed to return quoted forms instead of plain data, which breaks some use cases (such as `clj-github.state-flow-helper`). This reverts `build-spec` to its old behavior, fixing breakage in `clj-github.state-flow-helper` as well as some direct calls from clients (now documented as not recommended).
| (:import (java.util.regex Pattern))) | ||
|
|
||
|
|
||
| (defn- spec-type [spec] |
There was a problem hiding this comment.
Simplifies cond + defmethods into a simple cond (as this is not open for external extension)
| (defn -add-default-content-type | ||
| [response] | ||
| (assoc-in response [:headers :content-type] "application/json")) | ||
|
|
||
| (defn add-default-content-type [response] | ||
| `(let [responder# (fake/responder ~response)] | ||
| (fn [origin-fn# opts# callback#] | ||
| ((or callback# identity) | ||
| (responder# origin-fn# opts# -add-default-content-type))))) |
| ((or callback identity) | ||
| (responder orig-fn opts force-json))))) | ||
|
|
||
| (defn ^:internal build-spec |
There was a problem hiding this comment.
Returns plain data again, instead of quoted forms
| `(fake/with-fake-http ~(build-spec spec) | ||
| ~@body)) | ||
| `(fake/with-fake-http | ||
| (build-spec ~(mapv #(if (-> % meta :path) `{:path ~%} %) spec)) |
There was a problem hiding this comment.
Preserve :path as intended (feature from 0.8.0 release)
There was a problem hiding this comment.
Pull request overview
This PR restores clj-github.test-helpers/build-spec to return plain runtime values (instead of quoted forms), fixing breakage in clj-github.state-flow-helper’s mock-github-flow and adding a regression test to catch the issue in the future.
Changes:
- Reworked
build-specto produce concrete request/response specs (including responder functions) suitable forhttp-kit-fakeat runtime. - Updated
with-fake-githubto preserve the^:path“computed path” feature while still feedingbuild-specplain data. - Added a basic
mock-github-flowtest and bumped the library version.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
test/clj_github/state_flow_helper_test.clj |
Adds regression coverage ensuring mock-github-flow honors explicit response specs and returns parsed JSON bodies. |
src/clj_github/test_helpers.clj |
Restores runtime (non-quoted) build-spec behavior and adapts with-fake-github to keep computed-path support. |
project.clj |
Bumps version to 0.9.1-beta1. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
It was missing the leading slash in the mocked URL (no it was not actually mocked by default).
There was a problem hiding this comment.
internal workflows won't run in public repos like this, they always error out, so there is no point in keeping them
build-specwas changed to return quoted forms instead of plain data, which breaks some use cases (such asclj-github.state-flow-helper).This reverts
build-specto its old behavior, fixing breakage inclj-github.state-flow-helperas well as some direct calls from clients (now documented as not recommended).It also adds a basic test case for
clj-github.state-flow-helper(that would detect the issue).