-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
65 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package main | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestLoadsettings(t *testing.T) { | ||
var setting Setting | ||
var actual Setting | ||
var err error | ||
var errorText string | ||
|
||
// | ||
errorText = "The function should not overload SourceLang / TargetLang if eigher is not set." | ||
setting = Setting{ | ||
AuthKey: "test", | ||
SourceLang: "EN", | ||
TargetLang: "JA", | ||
} | ||
actual, err = LoadSettings(setting, false) | ||
if err != nil { | ||
t.Fatalf(errorText+"\n%#v", err) | ||
} | ||
if setting.AuthKey != actual.AuthKey || | ||
setting.SourceLang != actual.SourceLang || | ||
setting.TargetLang != actual.TargetLang { | ||
t.Fatalf(errorText+"\nExpected: %#v\nActual: %#v", setting, actual) | ||
} | ||
|
||
// | ||
errorText = "The function should occur error if AuthKey is not set." | ||
expectedErrorText := "No deepl token is set." // DRY... | ||
setting = Setting{ | ||
AuthKey: "", | ||
SourceLang: "EN", | ||
TargetLang: "JA", | ||
} | ||
actual, err = LoadSettings(setting, false) | ||
if err == nil { | ||
t.Fatalf(errorText+"\nReturned: %#v", actual) | ||
} else if err.Error() != expectedErrorText { | ||
t.Fatalf(errorText+"\nExpected: %s\nActual: %s", expectedErrorText, err.Error()) | ||
} | ||
|
||
// | ||
errorText = "The function should occur error if SourceLang == TargetLang" | ||
setting = Setting{ | ||
AuthKey: "test", | ||
SourceLang: "EN", | ||
TargetLang: "EN", | ||
} | ||
actual, err = LoadSettings(setting, false) | ||
if err == nil { | ||
t.Fatalf(errorText+"\nInputed: %#v", setting) | ||
} | ||
} | ||
|
||
func TestTranslate(t *testing.T) {} |