Skip to content

fix: remove getEnvValue and add ensureTruthy#581

Merged
exKAZUu merged 2 commits intomainfrom
chore/move-ensure-truthy
Jan 24, 2026
Merged

fix: remove getEnvValue and add ensureTruthy#581
exKAZUu merged 2 commits intomainfrom
chore/move-ensure-truthy

Conversation

@exKAZUu
Copy link
Copy Markdown
Member

@exKAZUu exKAZUu commented Jan 24, 2026

No description provided.

Co-authored-by: WillBooster (Codex CLI) <agent@willbooster.com>
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @exKAZUu, 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 refactors the shared-lib package by extracting the ensureTruthy utility function into its own dedicated assert module. This change improves the organization and modularity of the library's codebase, making it easier to manage assertion-related logic. The public API remains consistent as the function is re-exported from the main index.ts file, and new tests have been added to ensure its continued correct behavior.

Highlights

  • New Assertion Module: A new file, packages/shared-lib/src/assert.ts, has been introduced to encapsulate assertion-related utility functions.
  • Function Relocation: The ensureTruthy function, which validates if a value is truthy and throws an error if not, has been moved into the newly created assert.ts module.
  • Public API Maintenance: The main packages/shared-lib/src/index.ts file has been updated to re-export ensureTruthy from the new assert.js module, ensuring no breaking changes to the library's public interface.
  • Dedicated Unit Tests: A new test file, packages/shared-lib/test/assert.test.ts, has been added to provide comprehensive unit tests for the ensureTruthy function using Vitest.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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
Copy Markdown
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

このプルリクエストは ensureTruthy 関数を新しい assert モジュールに移動し、テストを追加するリファクタリングですね。コードは全体的にきれいで、目的も明確です。テストケースを拡充して、より多くの偽値(falsy values)をカバーすることで、関数の堅牢性をさらに高めることができると思います。具体的な提案をコメントしましたので、ご確認ください。

Comment on lines +5 to +12
test('ensureTruthy returns the value when truthy', () => {
expect(ensureTruthy('value', 'ok')).toBe('ok');
expect(ensureTruthy('value', 1)).toBe(1);
});

test('ensureTruthy throws when value is falsy', () => {
expect(() => ensureTruthy('value', '')).toThrow('The value of "value" must be truthy.');
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

テストのカバレッジを向上させるために、より多くの偽値(falsy values)と真値(truthy values)をテストすることをお勧めします。
現在のテストでは偽値として空文字列 ('') しかチェックされていませんが、0, false, null, undefined, NaN といった他の偽値でも ensureTruthy が正しくエラーをスローすることを確認すると、より堅牢になります。
vitesttest.each を使うと、複数の偽値のケースを簡潔に記述できます。

同様に、真値のテストケースも拡充すると良いでしょう。

Suggested change
test('ensureTruthy returns the value when truthy', () => {
expect(ensureTruthy('value', 'ok')).toBe('ok');
expect(ensureTruthy('value', 1)).toBe(1);
});
test('ensureTruthy throws when value is falsy', () => {
expect(() => ensureTruthy('value', '')).toThrow('The value of "value" must be truthy.');
});
test('ensureTruthy returns the value when truthy', () => {
expect(ensureTruthy('value', 'ok')).toBe('ok');
expect(ensureTruthy('value', 1)).toBe(1);
expect(ensureTruthy('value', true)).toBe(true);
const obj = {};
expect(ensureTruthy('value', obj)).toBe(obj);
const arr: unknown[] = [];
expect(ensureTruthy('value', arr)).toBe(arr);
});
test.each([
{ name: 'empty string', value: '' },
{ name: 'zero', value: 0 },
{ name: 'false', value: false },
{ name: 'null', value: null },
{ name: 'undefined', value: undefined },
{ name: 'NaN', value: NaN },
])('ensureTruthy throws when value is falsy: $name', ({ value }) => {
expect(() => ensureTruthy('value', value)).toThrow('The value of "value" must be truthy.');
});

@exKAZUu exKAZUu changed the title refactor: move ensureTruthy to assert module fix: remove getEnvValue and add ensureTruthy Jan 24, 2026
@exKAZUu exKAZUu enabled auto-merge (squash) January 24, 2026 12:30
@exKAZUu exKAZUu merged commit b32c50f into main Jan 24, 2026
8 checks passed
@exKAZUu exKAZUu deleted the chore/move-ensure-truthy branch January 24, 2026 12:31
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