-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cdp): hog transformations for geoip (#27646)
Co-authored-by: Ben White <[email protected]>
- Loading branch information
1 parent
0efdbdc
commit 24e9d94
Showing
6 changed files
with
313 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { Hub } from '../types' | ||
import { HogFunctionManager } from './hog-function-manager' | ||
|
||
describe('HogFunctionManager', () => { | ||
let hub: Hub | ||
let manager: HogFunctionManager | ||
|
||
beforeEach(() => { | ||
hub = { | ||
mmdb: undefined, // No MMDB configured | ||
postgres: { | ||
query: jest.fn().mockResolvedValue({ rows: [] }), | ||
transaction: jest.fn(), | ||
}, | ||
CELERY_DEFAULT_QUEUE: 'celery-default', | ||
PLUGINS_CELERY_QUEUE: 'plugins-celery', | ||
OBJECT_STORAGE_ENABLED: true, | ||
OBJECT_STORAGE_REGION: '', | ||
OBJECT_STORAGE_ENDPOINT: '', | ||
OBJECT_STORAGE_ACCESS_KEY_ID: '', | ||
OBJECT_STORAGE_SECRET_ACCESS_KEY: '', | ||
OBJECT_STORAGE_BUCKET: '', | ||
statsd: { | ||
timing: jest.fn(), | ||
increment: jest.fn(), | ||
gauge: jest.fn(), | ||
close: jest.fn(), | ||
}, | ||
instanceId: 'test', | ||
capabilities: {}, | ||
} as any as Hub | ||
|
||
manager = new HogFunctionManager(hub) | ||
}) | ||
|
||
describe('start()', () => { | ||
it('should fail if transformations are enabled but MMDB is not configured', async () => { | ||
await expect(manager.start(['transformation'])).rejects.toThrow( | ||
'GeoIP transformation requires MMDB to be configured. Please ensure the MMDB file is properly set up.' | ||
) | ||
}) | ||
|
||
it('should start successfully if MMDB is configured', async () => { | ||
hub.mmdb = {} as any // Mock MMDB as configured | ||
await expect(manager.start(['transformation'])).resolves.not.toThrow() | ||
}) | ||
|
||
it('should start successfully if transformations are not enabled', async () => { | ||
await expect(manager.start(['destination'])).resolves.not.toThrow() | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.