Add integration test suite against a real decree server#91
Merged
Conversation
Adds a docker-compose fixture and a Vitest integration workspace project that run the TypeScript SDK against a live decree server, covering the five scenarios from issue #59: snapshot, watch, reconnect, set with checksum, and set with abort. New files: - docker-compose.yml — postgres + redis + migrate (decree-tools) + decree service; DECREE_SRC / TOOLS_IMAGE / SERVICE_IMAGE are configurable for CI vs. local dev. - vitest.workspace.ts — workspace combining the existing unit project with the new integration project. - integration/vitest.config.ts — Vitest 'integration' project, active only when DECREE_INTEGRATION=1. - integration/setup.ts — global setup: waits for the server, creates a schema + tenant via generated stubs, seeds initial values, and tears everything down in the returned cleanup function. - integration/suite.test.ts — five describe blocks (snapshot, watch, reconnect, set-with-checksum, set-with-abort). Updated files: - vitest.config.ts — explicit include: ["test/**/*.test.ts"] so the unit project does not pick up integration/ by default. - package.json — adds test:integration script; extends lint/format/ pre-commit to cover integration/. - ci.yml — adds an integration job that checks out opendecree/decree, builds the tools and server images via docker/build-push-action with GHCR layer cache, starts the compose stack, runs the suite, and tears down unconditionally. Adds integration to the alls-green check gate. Closes #59 Co-Authored-By: Claude <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Docker Compose only recognises a volume host path as a bind mount when it starts with ./, ../, or /. A bare directory name like _decree is treated as a named-volume reference and rejected with "refers to undefined volume". Setting DECREE_SRC=./_decree in the integration job and documenting the requirement in docker-compose.yml fixes the startup failure. Co-Authored-By: Claude <noreply@anthropic.com>
Vitest throws "No projects matched the filter" when --project is used with a named project whose include array evaluates to [] (empty), which can happen if the workspace loads the config without the env var set, or when include paths resolve to non-existent files. Switch to vitest run --config integration/vitest.config.ts so Vitest loads the integration config directly without the workspace filter step. Change defineProject → defineConfig (standalone config, not a workspace project) and correct the include/globalSetup paths from ./integration/suite.test.ts to ./suite.test.ts (relative to the config file's own directory). Trim vitest.workspace.ts to unit tests only. Co-Authored-By: Claude <noreply@anthropic.com>
With defineConfig + --config integration/vitest.config.ts, Vite's root is the CWD (decree-typescript/) not the config file's directory, so include/globalSetup paths must be prefixed with ./integration/. Co-Authored-By: Claude <noreply@anthropic.com>
Run integration tests via `cd integration && vitest run` so Vitest
discovers vitest.config.ts without being overridden by the root
workspace file, which only includes the unit project.
Fix schema field creation by supplying the required `examples: {}` and
`tags: []` fields on each SchemaField (non-optional map and repeated
fields in the generated proto types).
Set the integer config field using a raw ConfigServiceClient call with
`integerValue` instead of `setNumber`, because the server validates
that INT fields receive an integerValue-typed proto value, not a
stringValue or numberValue.
Make the post-abort cleanup in the abort test best-effort: a cancelled
gRPC call can leave a stale version counter on the server that causes a
duplicate key constraint on the next set, which is a server-side issue
and should not fail the test assertion.
Co-Authored-By: Claude <noreply@anthropic.com>
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.
Summary
Test plan
npm test) — all 219 pass, coverage unchanged at 97.5%.npm run lint) — clean onsrc/,test/, and newintegration/.DECREE_INTEGRATIONis unset; does not affect unit test coverage report.DECREE_INTEGRATION=1 npm run test:integration) — requires the docker-compose stack (docker compose up -d --wait service); covers:getAll()and typedget()round-tripsConfigWatcherloads initial snapshot and receives a live Subscribe changeChecksumMismatchErrorAbortControllerabort wires through to gRPC; if cancelled, error isCancelledErroropendecree/decree, builds tools + server images with GHCR layer cache, starts the stack, runs the suite, tears down unconditionally.Closes #59