forked from ratmie/times-all-bot-lambda
-
Notifications
You must be signed in to change notification settings - Fork 0
refactor: ソースコードをsrcに移動し疎結合化・テスト追加 #17
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
19b4f11
refactor: ビジネスロジックをsrc/libに純粋関数として抽出
eai04191 cbf0708
refactor: Slackアプリの構成をsrcディレクトリに分離
eai04191 5130202
refactor: ソースファイルをsrcディレクトリに移動
eai04191 1a354a3
refactor: src移動に伴う参照元の更新とvalibot導入
eai04191 4c0ae56
feat: node:testによる単体テストを追加しCIにテストステップを追加
eai04191 889f6fc
chore: typecheckスクリプトから重複する--noEmitフラグを削除
eai04191 92589a5
fix: WORKSPACE_URLの末尾スラッシュを禁止しenv.testのprocess.env復元を安全化
eai04191 f82ec6c
fix: joinBotToTimesChannelsにページネーション処理を追加
eai04191 076e53e
fix: conversations.listのエラーレスポンスをthrowするように修正
eai04191 b18370e
fix: joinTimesChannelsをトップレベルawaitに変更
eai04191 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 was deleted.
Oops, something went wrong.
This file contains hidden or 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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,76 @@ | ||
| import assert from 'node:assert/strict'; | ||
| import { afterEach, beforeEach, describe, it } from 'node:test'; | ||
| import * as v from 'valibot'; | ||
| import { loadEnv } from '../env.ts'; | ||
|
|
||
| describe('loadEnv', () => { | ||
| const validEnv = { | ||
| SLACK_SIGNING_SECRET: 'secret', | ||
| SLACK_BOT_TOKEN: 'xoxb-token', | ||
| TIMES_ALL_CHANNEL_ID: 'C12345', | ||
| WORKSPACE_URL: 'https://workspace.slack.com', | ||
| }; | ||
|
|
||
| let originalEnv: NodeJS.ProcessEnv; | ||
|
|
||
| beforeEach(() => { | ||
| originalEnv = {}; | ||
| for (const key of Object.keys(validEnv)) { | ||
| originalEnv[key] = process.env[key]; | ||
| } | ||
| for (const [key, value] of Object.entries(validEnv)) { | ||
| process.env[key] = value; | ||
| } | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| for (const key of Object.keys(validEnv)) { | ||
| const original = originalEnv[key]; | ||
| if (original === undefined) { | ||
| delete process.env[key]; | ||
| } else { | ||
| process.env[key] = original; | ||
| } | ||
| } | ||
| }); | ||
|
|
||
| it('すべての環境変数が設定されている場合はEnvオブジェクトを返す', () => { | ||
| const env = loadEnv(); | ||
| assert.deepEqual(env, { | ||
| slackSigningSecret: 'secret', | ||
| slackBotToken: 'xoxb-token', | ||
| timesAllChannelId: 'C12345', | ||
| workspaceUrl: 'https://workspace.slack.com', | ||
| }); | ||
| }); | ||
|
|
||
| it('SLACK_SIGNING_SECRETが未設定の場合はValiErrorを投げる', () => { | ||
| delete process.env['SLACK_SIGNING_SECRET']; | ||
| assert.throws(() => loadEnv(), v.ValiError); | ||
| }); | ||
|
|
||
| it('SLACK_BOT_TOKENが未設定の場合はValiErrorを投げる', () => { | ||
| delete process.env['SLACK_BOT_TOKEN']; | ||
| assert.throws(() => loadEnv(), v.ValiError); | ||
| }); | ||
|
|
||
| it('TIMES_ALL_CHANNEL_IDが未設定の場合はValiErrorを投げる', () => { | ||
| delete process.env['TIMES_ALL_CHANNEL_ID']; | ||
| assert.throws(() => loadEnv(), v.ValiError); | ||
| }); | ||
|
|
||
| it('WORKSPACE_URLが未設定の場合はValiErrorを投げる', () => { | ||
| delete process.env['WORKSPACE_URL']; | ||
| assert.throws(() => loadEnv(), v.ValiError); | ||
| }); | ||
|
|
||
| it('WORKSPACE_URLが不正なURLの場合はValiErrorを投げる', () => { | ||
| process.env['WORKSPACE_URL'] = 'not-a-url'; | ||
| assert.throws(() => loadEnv(), v.ValiError); | ||
| }); | ||
|
|
||
| it('WORKSPACE_URLが末尾スラッシュを含む場合はValiErrorを投げる', () => { | ||
| process.env['WORKSPACE_URL'] = 'https://workspace.slack.com/'; | ||
| assert.throws(() => loadEnv(), v.ValiError); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.