Skip to content

keyv - chore: adding tests for code coverage#1845

Merged
jaredwray merged 1 commit intomainfrom
keyv---chore-adding-tests-for-code-coverage
Feb 16, 2026
Merged

keyv - chore: adding tests for code coverage#1845
jaredwray merged 1 commit intomainfrom
keyv---chore-adding-tests-for-code-coverage

Conversation

@jaredwray
Copy link
Owner

@jaredwray jaredwray commented Feb 16, 2026

Please check if the PR fulfills these requirements

  • Followed the Contributing and Code of Conduct guidelines.
  • Tests for the changes have been added (for bug fixes/features) with 100% code coverage.

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
keyv - chore: adding tests for code coverage

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @jaredwray, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the test suite for the keyv package by introducing new test cases. These additions aim to improve code coverage and ensure robust behavior for specific scenarios, including the handling of non-serializable Symbol values and the correct detection of iterable adapters based on URL configurations.

Highlights

  • Symbol Serialization Error Handling: Added a test case to verify that attempting to set a Symbol as a value in Keyv correctly throws an error and emits an 'error' event, confirming that symbols are not serializable.
  • Iterable Adapter Detection by URL: Introduced a test to ensure that Keyv can successfully detect and utilize an iterable adapter when its configuration includes a URL, even if the dialect option is not explicitly provided.
Activity
  • No specific activity (comments, reviews, progress updates) has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds two new tests to improve code coverage. The first test verifies that setting a Symbol value correctly throws an error and emits an error event. The second test ensures that Keyv can detect an iterable adapter based on the store's URL when a dialect is not specified. My review includes a suggestion to refactor the mock store in the second test to make it simpler, more maintainable, and more accurate.

Comment on lines +1016 to +1041
const map = new Map<string, unknown>();
const store = {
opts: { url: "redis://localhost:6379" },
async get(key: string) {
return map.get(key);
},
async set(key: string, value: unknown) {
map.set(key, value);
},
async delete(key: string) {
return map.delete(key);
},
async clear() {
map.clear();
},
async *iterator(namespace?: string) {
for (const [key, value] of map) {
if (!namespace || key.startsWith(namespace)) {
yield [key, value];
}
}
},
on() {
return store;
},
};
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The mock store object is more complex than necessary for this test. The get, set, delete, clear, and iterator methods are not actually used by the logic under test, which only checks for the presence of the iterator method. You can simplify this by using test.vi.fn() for the unused methods and providing an empty generator for iterator. This also removes the need for the map variable.

Additionally, the on() method mock is incorrect. It should accept arguments and return the store instance to be compliant with the IEventEmitter interface. Using test.vi.fn().mockReturnValue(store) is a better approach.

const store = {
	opts: { url: "redis://localhost:6379" },
	get: test.vi.fn(),
	set: test.vi.fn(),
	delete: test.vi.fn(),
	clear: test.vi.fn(),
	async *iterator() { /* empty */ },
	on: test.vi.fn(),
};
store.on.mockReturnValue(store);

@codecov
Copy link

codecov bot commented Feb 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.95%. Comparing base (a04589c) to head (568fd6c).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1845      +/-   ##
==========================================
+ Coverage   99.79%   99.95%   +0.16%     
==========================================
  Files          32       32              
  Lines        2432     2432              
  Branches      448      448              
==========================================
+ Hits         2427     2431       +4     
+ Misses          5        1       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jaredwray jaredwray merged commit e35f9de into main Feb 16, 2026
10 checks passed
@jaredwray jaredwray deleted the keyv---chore-adding-tests-for-code-coverage branch February 16, 2026 23:48
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