Skip to content

Commit

Permalink
ci: 调整脚中对于环境变量的设置
Browse files Browse the repository at this point in the history
  • Loading branch information
caixw committed Oct 16, 2024
1 parent 8dd16d9 commit 9b063d0
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cmd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- name: Test
env:
LANG: en
LANGUAGE: en
run: |
cd cmd/web
go test -v ./...
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:

- name: Test
env:
LANG: en
LANGUAGE: en
run: go test $(go list ./... | grep -v cache/caches) -v -coverprofile='coverage.txt' -covermode=atomic -p=1 -parallel=1

- name: Upload Coverage report
Expand Down
2 changes: 1 addition & 1 deletion mimetype/html/view_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func newServer(a *assert.Assertion, lang string) web.Server {

func TestInstallView(t *testing.T) {
a := assert.New(t, false)
s := newServer(a, "und")
s := newServer(a, "und") // und 被解析为 language.Und,将会尝试读取系统的本地化信息
html.InstallView(s, false, os.DirFS("./testdata/view"), "*.tpl")

defer servertest.Run(a, s)()
Expand Down
2 changes: 1 addition & 1 deletion server/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ type (
// 框架中的日志输出时,如果该信息实现了 [web.LocaleStringer] 接口,
// 将会转换成此设置项的语言。
//
// 如果为空,则会尝试读取当前系统的本地化信息。
// 如果为空,即 [language.Und],则会尝试读取当前系统的本地化信息。
Language language.Tag

locale *locale.Locale
Expand Down
6 changes: 6 additions & 0 deletions server/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"github.com/issue9/assert/v4"
"github.com/issue9/mux/v9/header"
"golang.org/x/text/language"

"github.com/issue9/web/mimetype/html"
)
Expand All @@ -29,4 +30,9 @@ func TestSanitizeOptions(t *testing.T) {
NotNil(o.locale).
NotNil(o.Codec).
NotZero(len(o.Plugins))

o, err = sanitizeOptions(&Options{
Language: language.MustParse("zh-Hant"),
}, typeHTTP)
a.NotError(err).NotNil(o).Equal(o.Language, language.MustParse("zh-Hant"))
}

0 comments on commit 9b063d0

Please sign in to comment.