test: verify this configuration by publishing through it - #4
Open
rmdes wants to merge 1 commit into
Open
Conversation
Adds a smoke test that publishes a note through the Micropub API, checks the file the content store received, and deletes it again. It runs on push and weekly, so a change in a published `@indiekit/*` package fails here rather than the next time somebody clones this repository. The GitHub content store is pointed at a local stub through its `baseUrl` option, so the test needs no access token, makes no network request and writes to no repository, while still exercising the plug-ins, preset, publication and syndicator options this repository ships. `test/indiekit.config.ci.js` imports the published configuration and overrides that one endpoint, so the configuration under test is the real one. Asserted: the publish returns 202 with a Location header, the note is filed at the Jekyll collection path the preset defines, the stored file contains a marker unique to the run, `q=config` advertises the post types, `q=syndicate-to` advertises the syndicator, and deleting the post removes the file. Not asserted: that the reported URL serves the post. This repository has no site generator, so that half belongs with a starter that does. The test names the missing-PASSWORD_SECRET case explicitly. Without it Indiekit redirects every route to first-run setup, and because redirects are followed the failure otherwise surfaces as an unexplained 200.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Following on from #903, where @paulrobertlloyd suggested example-config as
a good place to give a proof of concept for testing this way.
What it does
Publishes a note through the Micropub API, checks the file the content
store received, and deletes it again — on push, and weekly.
The GitHub content store is pointed at a local stub via its
baseUrloption, so the test needs no access token, makes no network request and
writes to no repository, while still exercising the plug-ins, preset,
publication and syndicator options configured here.
test/indiekit.config.ci.jsimports the published configuration andoverrides that one endpoint, so what is under test is the real config.
No secrets means it also runs on pull requests from forks.
Why
This repository depends on four
^1.0.0-betapackages. Its correctness isa function of packages that change often, and nothing was watching.
Reintroducing the bug fixed in #3 —
indiekit.config.jsimporting anundeclared
dotenv— the test fails with:The weekly run resolves the semver ranges rather than the lockfile, so a
change in a published package surfaces here rather than the next time
somebody clones this repository.
What it asserts
Publish returns 202 with a
Location; the note is filed in the Jekyllcollection the preset defines; the stored file contains a marker unique to
the run; the write is one the GitHub API would accept (branch, commit
message, valid base64);
q=configadvertises the post types;q=syndicate-toadvertises the syndicator; deleting removes the file.What it does not assert
That the advertised URL serves the post. There is no site generator here,
so that belongs with a starter that has one.
Notes
The test starts and stops its own server and refuses to run if the ports
are in use, so it cannot publish into a server it did not start. It also
names the missing-
PASSWORD_SECRETcase explicitly: without it Indiekitredirects every route to first-run setup, and because redirects are
followed the failure otherwise looks like an unexplained 200.