Skip to content

test: add unit test suite and run tests in CI - #27

Merged
ayoubfaouzi merged 1 commit into
mainfrom
feat/add-tests-and-ci
Aug 3, 2026
Merged

test: add unit test suite and run tests in CI#27
ayoubfaouzi merged 1 commit into
mainfrom
feat/add-tests-and-ci

Conversation

@ayoubfaouzi

@ayoubfaouzi ayoubfaouzi commented Aug 3, 2026

Copy link
Copy Markdown
Member

Summary

The project previously had zero tests, and CI only ran go build. This PR adds the first test suite and wires it into CI.

  • internal/webapihttptest-based tests for the API client covering Scan (multipart form fields, auth header, filename, error paths), Rescan (request body), FileExists, GetFile, GetFileStatus, ListFiles (including API error messages), SearchFiles (including error paths), Download, and Delete. No network access needed.
  • internal/util — tests for hashing, file read/write helpers, Exists/MkDir, slice helpers, and directory walking.
  • cmd — tests for the pure helpers: buildScanSummary (including the nested MultiAV extraction) and collectHashes/sha256Re.
  • CI — the workflow now runs go vet ./... and go test -race -v ./... on all three platforms in addition to the build.

Tests intentionally cover current behavior only; known bugs found during review (unchecked HTTP status codes in Rescan/Download/Delete, the short-read in util.ReadAll, etc.) will be fixed in follow-up PRs with their own regression tests.

Test plan

  • go build ./... && go vet ./... && go test -race ./... passes locally on linux.

Add an httptest-based test suite for the web API client (scan upload,
rescan, download, delete, search, listing, file status), tests for the
util helpers, and tests for the scan summary / hash collection helpers
in cmd. Extend the CI workflow to run go vet and go test -race in
addition to the build.
@ayoubfaouzi
ayoubfaouzi merged commit 94799cc into main Aug 3, 2026
3 checks passed
@ayoubfaouzi
ayoubfaouzi deleted the feat/add-tests-and-ci branch August 3, 2026 06:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant