Skip to content

Commit

Permalink
Fix Options.Validate test
Browse files Browse the repository at this point in the history
  • Loading branch information
tanaka0325 committed Jul 18, 2020
1 parent 94f3382 commit 675b8a5
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions kadai2/tanaka0325/imgconv/options_test.go
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
package imgconv
package imgconv_test

import (
"testing"

"github.com/gopherdojo/dojo8/kadai2/tanaka0325/imgconv"
)

func TestOption_validate(t *testing.T) {
func TestOptionsValidate(t *testing.T) {
notAllowdExt := "not_allowed_ext"
jpg := "jpg"
png := "png"
allowedList := []string{jpg, png}

tests := []struct {
name string
options Options
options imgconv.Options
args []string
isErr bool
}{
{
name: "err:Options.From is not allowed",
options: Options{
options: imgconv.Options{
From: &notAllowdExt,
To: &png,
},
Expand All @@ -27,7 +29,7 @@ func TestOption_validate(t *testing.T) {
},
{
name: "err:Options.To is not allowed",
options: Options{
options: imgconv.Options{
From: &jpg,
To: &notAllowdExt,
},
Expand All @@ -36,7 +38,7 @@ func TestOption_validate(t *testing.T) {
},
{
name: "ok",
options: Options{
options: imgconv.Options{
From: &jpg,
To: &png,
},
Expand All @@ -47,7 +49,7 @@ func TestOption_validate(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
err := tt.options.validate(tt.args)
err := tt.options.Validate(tt.args)
if (tt.isErr && err == nil) || (!tt.isErr && err != nil) {
t.Errorf("expect err is %t, but got err is %s", tt.isErr, err)
}
Expand Down

0 comments on commit 675b8a5

Please sign in to comment.