generated from gopherdojo/template
-
Notifications
You must be signed in to change notification settings - Fork 182
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
Kadai2 edm20627 #51
Open
keethii27
wants to merge
24
commits into
gopherdojo:master
Choose a base branch
from
keethii27:kadai2-edm20627
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+591
−0
Open
Kadai2 edm20627 #51
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
7dc7e7a
ひとまず動くものを作成
keethii27 5aed38c
ユーザ定義型を作成
keethii27 9dc9755
自作パッケージを作成
keethii27 7d5d81e
vlid関数をメソッドに変更
keethii27 7776099
微修正
keethii27 a504b57
画像変換処理のエラーハンドリング追加
keethii27 44bbfd1
削除フラグの追加
keethii27 87c6eb3
GoDocを生成する
keethii27 44e95d3
サンプル画像を追加
keethii27 f21ec02
README.md 追加
keethii27 49c5e89
.gitignore
keethii27 74fabfa
go mod tidy 実行'
keethii27 f4be072
.gitignoreの配置変更
keethii27 183f52f
課題1をコピー
keethii27 5fefe04
go moduleパス変更
keethii27 e1ba6c2
リファクタリング
keethii27 7caa18b
テスト追加
keethii27 c75f90f
fix エラーハンドリング追加
keethii27 6d344e9
fix タイポ
keethii27 3f72fd8
fix ネストが深いためValidメソッドをリファクタリング
keethii27 38cf933
fix TestValidに正 to 否、否 to 正ケースを追加
keethii27 539b81a
fix テスト用画像を使用しテストできるようにtastdataを作成
keethii27 1133222
fix DeleteOptionのテスト追加
keethii27 6d99bb2
fix 実際にテストでファイル削除しているか確認できるように修正
keethii27 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 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 |
---|---|---|
@@ -1,7 +1,10 @@ | ||
package imageconvert_test | ||
|
||
import ( | ||
"errors" | ||
"os" | ||
"reflect" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/edm20627/gopherdojo-studyroom/kadai2/edm20627/imageconvert" | ||
|
@@ -55,22 +58,41 @@ func TestGet(t *testing.T) { | |
|
||
func TestConvert(t *testing.T) { | ||
cases := []struct { | ||
name string | ||
filepaths []string | ||
from string | ||
to string | ||
name string | ||
filepaths []string | ||
from string | ||
to string | ||
deleteOption bool | ||
}{ | ||
{name: "jpg to png", filepaths: []string{"../testdata/img_1.jpg"}, from: "jpg", to: "png"}, | ||
{name: "png to gif", filepaths: []string{"../testdata/img_2.png"}, from: "png", to: "gif"}, | ||
{name: "gif to jpg", filepaths: []string{"../testdata/img_3.gif"}, from: "gif", to: "jpg"}, | ||
{name: "jpg to png", filepaths: []string{"../testdata/img_1.jpg"}, from: "jpg", to: "png", deleteOption: false}, | ||
{name: "png to gif", filepaths: []string{"../testdata/img_2.png"}, from: "png", to: "gif", deleteOption: false}, | ||
{name: "gif to jpg", filepaths: []string{"../testdata/img_3.gif"}, from: "gif", to: "jpg", deleteOption: false}, | ||
{name: "jpg to png", filepaths: []string{"../testdata/img_1.jpg"}, from: "jpg", to: "png", deleteOption: true}, | ||
{name: "png to gif", filepaths: []string{"../testdata/img_2.png"}, from: "png", to: "gif", deleteOption: true}, | ||
{name: "gif to jpg", filepaths: []string{"../testdata/img_3.gif"}, from: "gif", to: "jpg", deleteOption: true}, | ||
} | ||
|
||
for _, c := range cases { | ||
t.Run(c.name, func(t *testing.T) { | ||
ci := imageconvert.ConvertImage{Filepaths: c.filepaths, To: c.to} | ||
imageconvert.OsRemove = func(path string) error { | ||
for _, filepath := range c.filepaths { | ||
if path == filepath { | ||
return nil | ||
} | ||
} | ||
return errors.New("failed to delete for conversion source image") | ||
} | ||
|
||
ci := imageconvert.ConvertImage{Filepaths: c.filepaths, To: c.to, DeleteOption: c.deleteOption} | ||
if actual := ci.Convert(); actual != nil { | ||
t.Error(actual) | ||
} | ||
for _, filepath := range c.filepaths { | ||
targetFile := strings.Replace(filepath, c.from, c.to, 1) | ||
if err := os.Remove(targetFile); err != nil { | ||
t.Fatal(err) | ||
} | ||
} | ||
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. DeleteOptionのテストを追加しました。 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. メモ:
|
||
}) | ||
} | ||
} | ||
|
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.
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.
ちょっと大変ですがDeleteOptionのテストもできるとベストですね