-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restructure jobs router + Add heartbeat
- Loading branch information
Showing
6 changed files
with
140 additions
and
61 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
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,24 @@ | ||
import { bolt } from '@/api/slack'; | ||
|
||
import { heartbeat } from './heartbeat'; | ||
|
||
describe('test uptime heartbeat', function () { | ||
let postMessageSpy; | ||
beforeEach(() => { | ||
postMessageSpy = jest | ||
.spyOn(bolt.client.chat, 'postMessage') | ||
.mockImplementation(jest.fn()); | ||
}); | ||
afterEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
it('should send a message to slack', async () => { | ||
await heartbeat(); | ||
expect(postMessageSpy).toHaveBeenCalledTimes(1); | ||
expect(postMessageSpy).toHaveBeenCalledWith( | ||
expect.objectContaining({ | ||
text: 'Infra Hub is up', | ||
}) | ||
); | ||
}); | ||
}); |
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,15 @@ | ||
import * as Sentry from '@sentry/node'; | ||
|
||
import { bolt } from '@/api/slack'; | ||
import { INFRA_HUB_HEARTBEAT_CHANNEL } from '@/config'; | ||
|
||
export async function heartbeat() { | ||
try { | ||
await bolt.client.chat.postMessage({ | ||
channel: INFRA_HUB_HEARTBEAT_CHANNEL, | ||
text: 'Infra Hub is up', | ||
}); | ||
} catch (err) { | ||
Sentry.captureException(err); | ||
} | ||
} |
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