-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from nao1215/nchika/introduce-i18n
Introduce i18n
- Loading branch information
Showing
13 changed files
with
481 additions
and
72 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
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,67 @@ | ||
package csv | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestError_Error(t *testing.T) { | ||
t.Parallel() | ||
|
||
t.Run("should return the localized error message", func(t *testing.T) { | ||
t.Parallel() | ||
|
||
err := NewError(helperLocalizer(t), ErrStructSlicePointerID, "subMessage") | ||
|
||
got := err.Error() | ||
want := "value is not a pointer to a struct slice: subMessage" | ||
|
||
if got != want { | ||
t.Errorf("Error() = %v, want %v", got, want) | ||
} | ||
}) | ||
|
||
t.Run("should return the localized error message without subMessage", func(t *testing.T) { | ||
t.Parallel() | ||
|
||
err := NewError(helperLocalizer(t), ErrStructSlicePointerID, "") | ||
|
||
got := err.Error() | ||
want := "value is not a pointer to a struct slice" | ||
|
||
if got != want { | ||
t.Errorf("Error() = %v, want %v", got, want) | ||
} | ||
}) | ||
} | ||
|
||
func TestError_Is(t *testing.T) { | ||
t.Parallel() | ||
|
||
t.Run("should return true if the target error is the same as the error", func(t *testing.T) { | ||
t.Parallel() | ||
|
||
err := NewError(helperLocalizer(t), ErrStructSlicePointerID, "subMessage") | ||
target := NewError(helperLocalizer(t), ErrStructSlicePointerID, "subMessage") | ||
|
||
got := err.Is(target) | ||
want := true | ||
|
||
if got != want { | ||
t.Errorf("Is() = %v, want %v", got, want) | ||
} | ||
}) | ||
|
||
t.Run("should return false if the target error is not the same as the error", func(t *testing.T) { | ||
t.Parallel() | ||
|
||
err := NewError(helperLocalizer(t), ErrStructSlicePointerID, "subMessage") | ||
target := NewError(helperLocalizer(t), ErrEqualID, "") | ||
|
||
got := err.Is(target) | ||
want := false | ||
|
||
if got != want { | ||
t.Errorf("Is() = %v, want %v", got, want) | ||
} | ||
}) | ||
} |
Oops, something went wrong.