Skip to content

chore: added some tests for the server#67

Merged
Skarlso merged 1 commit intomainfrom
add-some-tests
Feb 1, 2026
Merged

chore: added some tests for the server#67
Skarlso merged 1 commit intomainfrom
add-some-tests

Conversation

@Skarlso
Copy link
Collaborator

@Skarlso Skarlso commented Feb 1, 2026

Problem Statement

What is the problem you're trying to solve?

Related Issue

Fixes #...

Proposed Changes

How do you like to solve the issue and why?

Checklist

  • I have read the contribution guidelines
  • All commits are signed with git commit --signoff
  • My changes have reasonable test coverage
  • All tests pass with make test
  • I ensured my PR is ready for review with make reviewable

Adds a new comprehensive test suite at pkg/server/server_test.go (+611 lines). Introduces mock Bitwarden client implementations and tests covering server initialization, readiness/liveness endpoints, client retrieval and response handling, and full CRUD-like secret operations (get, get by IDs, list, create, update, delete). Tests exercise success and error paths, HTTP status codes, response bodies, and error propagation (including marshal and invalid/no-client contexts).

@coderabbitai
Copy link

coderabbitai bot commented Feb 1, 2026

Walkthrough

Adds a comprehensive Go test suite at pkg/server/server_test.go (611 new lines) with mock Bitwarden client implementations and tests covering server construction, readiness/liveness endpoints, CRUD-like secret operations, client/response handling, and error-path validations.

Changes

Cohort / File(s) Summary
Server initialization & health
pkg/server/server_test.go
Adds tests for server construction (TestNewServer) and health endpoints (TestReadyEndpoint, TestLiveEndpoint) using mocked client implementations.
Secrets CRUD & error paths
pkg/server/server_test.go
Adds extensive tests for secret operations: GetSecretHandler, GetByIdsSecretHandler, ListSecretsHandler, DeleteSecretHandler, CreateSecretHandler, UpdateSecretHandler, covering success and failure cases, status codes, and response bodies.
Client & response utilities
pkg/server/server_test.go
Adds tests for client retrieval (TestGetClient), response handling (TestHandleResponse, TestHandleResponseMarshalError), and invalid-context/request scenarios (TestHandlerWithInvalidBody, TestHandlerWithNoClientInContext).

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@pkg/server/server_test.go`:
- Around line 17-32: The import block in pkg/server/server_test.go is not
gci-formatted; run the repo's configured gci command to reorder imports into the
project's sections (e.g., stdlib, external, internal) and reformat the import
block shown in the diff so CI lint passes; update the import statements in this
file (the import(...) block) and commit the change.
- Around line 103-121: In TestReadyEndpoint and TestLiveEndpoint update the
httptest.NewRequest calls to use http.NoBody instead of nil for the request body
(replace the body arg in the NewRequest call inside TestReadyEndpoint and the
NewRequest call inside TestLiveEndpoint) to satisfy gocritic; no new imports are
required since http is already imported.

Signed-off-by: Gergely Brautigam <182850+Skarlso@users.noreply.github.com>
@Skarlso Skarlso merged commit 605abab into main Feb 1, 2026
4 of 5 checks passed
@Skarlso Skarlso deleted the add-some-tests branch February 2, 2026 06:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant