Skip to content

Commit

Permalink
enhancing unittest for missing localization text
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Loesch committed Jan 3, 2020
1 parent 1661e76 commit ffe25e1
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions v2/goi18n/merge_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ import (
)

type testCase struct {
name string
inFiles map[string][]byte
sourceLanguage language.Tag
outFiles map[string][]byte
deleteFiles []string
name string
inFiles map[string][]byte
sourceLanguage language.Tag
outFiles map[string][]byte
deleteFiles []string
expectedExitCode int
}

func expectFile(s string) []byte {
Expand All @@ -35,6 +36,15 @@ func TestMerge(t *testing.T) {
"active.en-US.toml": []byte("1HelloMessage = \"Hello\"\n"),
},
},
{
name: "single identity, no localization text",
sourceLanguage: language.AmericanEnglish,
inFiles: map[string][]byte{
"one.en-US.toml": []byte("1HelloMessage = \"\"\n"),
},
outFiles: map[string][]byte{},
expectedExitCode: 1,
},
{
name: "plural identity",
sourceLanguage: language.AmericanEnglish,
Expand Down Expand Up @@ -518,8 +528,8 @@ zero = "{{.Count}} unread emails"
}

args := append([]string{"merge", "-sourceLanguage", testCase.sourceLanguage.String(), "-outdir", outdir}, infiles...)
if code := testableMain(args); code != 0 {
t.Fatalf("expected exit code 0; got %d\n", code)
if code := testableMain(args); code != testCase.expectedExitCode {
t.Fatalf("expected exit code %d; got %d\n", testCase.expectedExitCode, code)
}

files, err := ioutil.ReadDir(outdir)
Expand Down

0 comments on commit ffe25e1

Please sign in to comment.