-
Notifications
You must be signed in to change notification settings - Fork 1
課題2 tokunaga #16
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: master
Are you sure you want to change the base?
課題2 tokunaga #16
Conversation
|
|
||
| // 画像変換テスト | ||
| func TestConvertImage(t *testing.T) { | ||
| t.Helper() |
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.
t.Helper() はヘルパー関数側で呼ぶので、この場合 SetupTestConvertImage() の中で呼んであげるのが適切かと思います
| } | ||
|
|
||
| // 画像変換テストの前後で変換後のファイルを削除する | ||
| func SetupTestConvertImage(t *testing.T, files []string) func() { |
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.
テスト用なのでわざわざ public にする必要はなさそう
| file, err := os.Open(filename) | ||
| if err != nil { | ||
| fmt.Fprintf(os.Stderr, "file open error: %v\n", err) | ||
| return err |
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.
一般的な話としてエラーを返してるならここで標準エラーに出力する必要はない気がしますね(エラーを出力するなら ConvertImage() を呼んだ側でやるほうが自然)
テストヘルパー
0bf8f77
-> interfaceをDecode, Encode単位に分割
テーブル駆動テスト
->b73b1d4
リファクタリング
main処理からflagのパース,画像変換コマンド切り出し
->70d7d8b
参考:
https://github.com/hashicorp/atlas-upload-cli
https://deeeet.com/writing/2014/12/18/golang-cli-test/