Skip to content

Commit

Permalink
add parallel unittest for fiberi18n
Browse files Browse the repository at this point in the history
  • Loading branch information
Skyenought committed May 17, 2023
1 parent 5c674a0 commit 9b76010
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions fiberi18n/i18n_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,50 @@ func TestI18nZH(t *testing.T) {
})
}
}

func TestParallelI18n(t *testing.T) {
type args struct {
lang language.Tag
name string
}
tests := []struct {
name string
args args
want string
}{
{
name: "hello world",
args: args{
name: "",
lang: language.Chinese,
},
want: "你好",
},
{
name: "hello alex",
args: args{
name: "alex",
lang: language.Chinese,
},
want: "你好 alex",
},
{
name: "hello peter",
args: args{
name: "peter",
lang: language.English,
},
want: "hello peter",
},
}
t.Parallel()
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := makeRequest(tt.args.lang, tt.args.name)
utils.AssertEqual(t, err, nil)
body, err := io.ReadAll(got.Body)
utils.AssertEqual(t, err, nil)
utils.AssertEqual(t, tt.want, string(body))
})
}
}

0 comments on commit 9b76010

Please sign in to comment.