Git, testing and delivery
Original on-site instruction. Practice and outside references are optional. Independent subject review and observed learner testing remain pending.
A repository records snapshots and relationships
Git separates the working tree, staging area and committed history. Editing a file changes the working tree. Adding selected changes stages a proposed snapshot; committing records that staged snapshot with metadata and parent relationships. A later unstaged edit is not included simply because the same file was staged earlier. Inspect both the unstaged diff and staged diff before committing. A useful commit is a coherent change whose purpose and verification can be explained, not a promise that every file in the directory was tested together.
In a fictional exercise, begin with a committed request handler. Edit validation and stage it, then edit its error text without staging again. The next commit contains the staged validation version, not the newer unstaged message. The working tree still contains that message afterward. `git status`, `git diff` and `git diff --staged` answer related but distinct questions. Reading these differences prevents a test run against one working tree from being described as a test of a different committed artifact.
Branches name lines of work, and a commit can have several descendants. Suppose main at M gains A, while a feature branch from M gains B. A merge combines histories and usually has both lines as parents when a merge commit is created. A clean textual merge does not prove semantic compatibility: A might rename a field while B introduces a query using the old name in a different file. Rebase instead replays changes onto another base and creates new commit identities. Rewriting history already shared with others requires coordination; use the project's established policy rather than force-pushing to make a graph look tidy.
Revert records a new commit reversing selected changes; it preserves the earlier history. Reset changes a reference and, depending on its mode, can also change staging/working state. These are not interchangeable recovery tools. For a published defect, a reviewed revert can be more understandable than erasing shared history. A reverted application still needs schema/data compatibility, so Git alone cannot reverse an irreversible migration or an external side effect.
Never commit passwords, tokens or private fixture data. Removing a credential from the latest file leaves earlier copies in history and may leave clones or build logs. Revoke/rotate a genuinely exposed credential through the appropriate authorized process; deleting text is not revocation. Ignore rules prevent some untracked files from being added inadvertently but do not make already tracked secrets disappear. This course's exercises use fictional identities and temporary data; no real credential is needed for the repository experiment.
Tests establish claims at named boundaries
A unit test isolates a rule, such as permission predicate or price calculation. An integration test checks the actual connection between components: the route must call validation with a trusted principal, write the intended transaction and serialize an authorized result. A browser test checks the visible interaction, including keyboard access, loading/error states and recovery. These layers overlap, but one does not automatically supply the observations of another. The preserved native test in which a correct helper is bypassed by a route is the concrete reason to keep route-level negative tests.
Write expected results from the specification before invoking the implementation. For an order with two independent 500-cent lines, the expected total is 1000. Do not compute the expected total with the same report query whose join grain is under investigation. Include emptiness, duplicate values, malformed data, denied access, stale state and failures after partial work has begun. A test that asserts only “an exception occurred” can miss a partially committed row; inspect the post-failure state as well.
Use isolated fixtures. A database test should create known fictional rows in a disposable database or a deliberately isolated test schema, not query learner or production records. Control time, random seeds and external responses where needed for reproducibility, and label a simulated boundary as simulated. Mocking a database exception demonstrates the coordinator's selected reaction, while a real constraint failure demonstrates more of the database transaction boundary. Neither establishes a deployed database engine's complete concurrency or crash behavior.
For asynchronous UI behavior, give tests explicit response control instead of hoping a timing delay reproduces a race. Start A, start B, complete B successfully, then reject A. The displayed state must still belong to B. Repeat with B empty, malformed, denied and disconnected. A fixed sleep that happens to pass once is weak evidence that the correct completion event was observed. Wait for the state that expresses the contract and record what was actually tested.
Cross-browser work should target meaningful platform differences and supported configurations. A layout can render well in one browser while keyboard focus, native validation, date inputs or an API behave differently elsewhere. Use semantic markup, feature detection where appropriate and a declared support policy. Automated accessibility checks can find certain structural defects; they do not replace inspection of focus order, understandable error recovery or observed use with assistive technology. Do not claim a real mobile-device test from a desktop viewport emulation.
A delivery pipeline must identify the artifact
Continuous integration runs a declared set of checks on an identified revision in a controlled environment. A pipeline might install pinned dependencies, perform syntax/type/build checks, run unit/integration fixtures and package an artifact. A green result is bounded by its actual job definitions and environment. If the build tested revision A but deployment takes a fresh unverified working tree B, the badge does not establish B's behavior. Record the commit, runtime/dependency versions, commands and artifact digest where useful.
Separate build-time configuration from runtime configuration and secrets. A static frontend cannot safely hold a server credential merely because the source uses an environment-variable name: build tools can embed values into delivered JavaScript. Inspect which variables become public artifacts. Dependency versions and a lockfile improve repeatability, while security updates still require evaluation; pinning a vulnerable package forever is not a sound maintenance policy. Run checks with the same relevant framework/database versions as the deployment or state the difference.
A deployment changes a serving system, not just a source folder. Specify where requests terminate, how application workers start, how static assets are served, where persistent state lives and how configuration reaches each process. A local development server is convenient for debugging but is not an automatic production serving configuration. Disable development-only behavior, use the framework's production checks and arrange transport/proxy configuration deliberately. Verify a real public route and its denied/failure paths after release; upload acknowledgement or a process-start message is not persistence or visitor-behavior evidence.
Use staged rollout where the environment supports it. A canary exposes a selected portion of traffic to the candidate under a stated policy; a blue/green approach switches between serving environments. Both require compatible state and a clear rollback decision. They do not make a destructive schema change reversible or remove the need to know which revision served a particular failed request. Avoid inventing traffic or a successful canary observation when the exercise only describes a plan.
Schema changes, backups and restoration
The original expand-and-contract case establishes mixed-version compatibility. Extend it into a release contract: first add a compatible representation, backfill under a justified rule, deploy readers/writers that preserve the transition invariant, reconcile data and remove the old representation only after all consumers and rollback needs are resolved. A migration can pass on an empty database and fail against historical rows. Test representative old records and mixed writer behavior, including interruption during backfill.
A backup has a scope, a point in time and a restoration procedure. A logical SQL dump represents selected database objects/data under its tool and transaction options; it is not automatically a byte-for-byte disk image, a complete collection of external files or a guarantee of every cluster role/setting. Restore into an isolated target, verify schema and constraints, reconcile counts and selected independent totals, then exercise the application against it. The fact that the backup file exists or that the dump command exited zero does not establish recoverability.
Recovery objectives express different limits. An acceptable data-loss interval concerns the recovery point; an acceptable outage duration concerns recovery time. If backups are hourly and a failure occurs 50 minutes after the last usable snapshot, restoring only that snapshot may lose those 50 minutes of later accepted changes. Additional logs/replication may change that result under an actual tested policy. A backup is not a substitute for a rollback compatible with the current data, and replication can reproduce an erroneous deletion rather than preserving the earlier intended state.
Observability connects symptoms to causes without disclosing unnecessary sensitive data. Record a request/run ID, serving revision, operation category, result and timing where appropriate; avoid logging passwords, bearer tokens and entire private bodies. A rising error rate, slow tail latency and a dependency failure answer different operational questions. A liveness endpoint can show that a process responds; a readiness check asks whether it can serve its essential workflow. Bounded synthetic transactions on fictional data can supply stronger evidence but need isolation and cleanup policies.
Optional release record and complete model
Commit C passes a helper-only authorization test. The package actually contains an unstaged route edit accepting `role=admin` from the request. A migration then removes customer_name while one C worker still reads it. The team has an hourly dump but has never restored one. Explain four independent defects in the release claim and specify the smallest useful evidence for each. Change the scenario so the package really is C but a request fails only after the audit insert begins.
Compare the complete changed-record reasoning
**Model reasoning.** First, the tested revision and packaged working tree differ. Record and test the exact artifact, inspecting staged/unstaged changes rather than claiming C covers another tree. Second, a helper test does not exercise the hostile role through the route; call that route as an ordinary fictional customer, request another customer's object and verify denial plus no mutation/private response. Third, the migration invalidates an old worker and code-only rollback; use compatible expand/backfill/read-write/contract stages and test mixed versions. Fourth, an untested dump is not a demonstrated restoration path; restore into a disposable target and reconcile database plus application behavior. In the changed case, inject the actual documented audit failure inside the local transaction and query both domain and audit state afterward. A clean error response alone does not show rollback. None of these tests authorizes a real external payment or establishes every production crash mode.
Evaluate on four equal criteria: accurate Git snapshot/history reasoning; independent expectations and real boundary tests; exact artifact/configuration/deployment correspondence; and compatible data recovery with explicit limits. Preserve the original migration and route-bypass investigations. No remote repository history, production deployment, real credential or learner record was changed to write it.