-
Notifications
You must be signed in to change notification settings - Fork 5
chore: remove localhost value for AGENT_INTERNAL_URL #224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
90702e7
5f10d65
b25ace3
98136eb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,13 @@ | ||
| import { CrossEnvConfig } from '@flatfile/cross-env-config' | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test setup contradicts PR objectives The current implementation sets a default value for Consider replacing this with tests that verify both success and error cases: -if (CrossEnvConfig.get('AGENT_INTERNAL_URL') == null) {
- process.env.AGENT_INTERNAL_URL = 'agent_internal_url'
-}
+describe('AGENT_INTERNAL_URL validation', () => {
+ const originalEnv = process.env.AGENT_INTERNAL_URL;
+
+ afterEach(() => {
+ process.env.AGENT_INTERNAL_URL = originalEnv;
+ });
+
+ test('throws error when AGENT_INTERNAL_URL is not set', () => {
+ delete process.env.AGENT_INTERNAL_URL;
+ expect(() => {
+ FlatfileListener.create((c) => {
+ c.on('foo', () => {});
+ });
+ }).toThrow('AGENT_INTERNAL_URL must be set in the environment');
+ });
+
+ test('creates listener successfully when AGENT_INTERNAL_URL is set', () => {
+ process.env.AGENT_INTERNAL_URL = 'test_url';
+ expect(() => {
+ FlatfileListener.create((c) => {
+ c.on('foo', () => {});
+ });
+ }).not.toThrow();
+ });
+});Also applies to: 7-9 |
||
| import { FlatfileListener } from './flatfile.listener' | ||
|
|
||
| describe('Client', () => { | ||
| let testFn: jest.Mock | ||
|
|
||
| if (CrossEnvConfig.get('AGENT_INTERNAL_URL') == null) { | ||
| process.env.AGENT_INTERNAL_URL = 'agent_internal_url' | ||
| } | ||
|
|
||
| beforeEach(() => { | ||
| testFn = jest.fn() | ||
| }) | ||
|
|
@@ -150,4 +155,21 @@ describe('Client', () => { | |
| expect(testFn).toHaveBeenCalledTimes(3) | ||
| }) | ||
| }) | ||
|
|
||
| describe('AGENT_INTERNAL_URL', () => { | ||
| test('throws error when not set', () => { | ||
| process.env.AGENT_INTERNAL_URL = undefined | ||
|
|
||
| try { | ||
| FlatfileListener.create((c) => { | ||
| c.on('foo', () => {}) | ||
| }) | ||
| } catch (e) { | ||
| expect(e).toBeInstanceOf(Error) | ||
| expect((e as Error).message).toBe( | ||
| 'AGENT_INTERNAL_URL must be set in the environment' | ||
| ) | ||
| } | ||
| }) | ||
| }) | ||
| }) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test setup needs revision to align with PR objectives.
The current test setup automatically sets a default value for
AGENT_INTERNAL_URL, which contradicts the PR's objective of requiring explicit environment variable definition. According to the PR objectives, the application should throw an error whenAGENT_INTERNAL_URLis not set.Consider these improvements:
AGENT_INTERNAL_URLis not setHere's a suggested approach: