mirror of https://github.com/Wox-launcher/Wox
refactor(test): improve test setup and error reporting
- Move test initialization code to separate initServices() function - Set default test language to English - Add detailed action reporting for test failures - Update Makefile to build plugin hosts before running tests - Remove unused i18n instruction file
This commit is contained in:
parent
f946e21e03
commit
2a6c1596cd
6
Makefile
6
Makefile
|
@ -70,7 +70,11 @@ dev: _check_deps
|
|||
$(MAKE) -C wox.plugin.host.python build
|
||||
$(MAKE) -C wox.ui.flutter/wox build
|
||||
|
||||
test: dev
|
||||
test:
|
||||
# build the plugin host to makesure the plugin host is working
|
||||
$(MAKE) -C wox.plugin.host.nodejs build
|
||||
$(MAKE) -C wox.plugin.host.python build
|
||||
|
||||
cd wox.core && go test ./...
|
||||
|
||||
only_test:
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
参考一下 @wpm.go @lang 文件中关于i18n的用法, 把 @ai_command.go 的i18n实现一下, 要求如下:
|
||||
|
||||
- 不要更改任何原有逻辑, 仅仅实现i18n
|
||||
- 实现i18n的时候, 不要在i18n后面添加注释
|
||||
- Log信息不需要添加翻译
|
||||
- plugin.Metadata的name,author不需要添加翻译
|
||||
- plugin.MetadataCommand的Description需要翻译
|
||||
- api.Notify需要翻译
|
||||
- plugin.QueryResult里面的title, subtitle需要翻译
|
||||
- definition.PluginSettingDefinitions里面的需要翻译
|
||||
- plugin.QueryResultAction的Name需要翻译
|
||||
- 对于有变量的字符串, 使用 fmt.Sprintf(i18n.GetI18nManager().TranslateWox(ctx, "plugin_sys_open_plugin_settings"), instance.Metadata.Name) 这种形式
|
||||
- 对于纯字符串的翻译, 直接使用 i18n:前缀的形式
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
description:
|
||||
globs:
|
||||
---
|
||||
|
|
@ -329,7 +329,7 @@ func TestCalculatorTime(t *testing.T) {
|
|||
runQueryTests(t, tests)
|
||||
}
|
||||
|
||||
func init() {
|
||||
func initServices() {
|
||||
ctx := context.Background()
|
||||
|
||||
// Initialize location
|
||||
|
@ -351,8 +351,7 @@ func init() {
|
|||
}
|
||||
|
||||
// Initialize i18n
|
||||
woxSetting := setting.GetSettingManager().GetWoxSetting(ctx)
|
||||
err = i18n.GetI18nManager().UpdateLang(ctx, woxSetting.LangCode)
|
||||
err = i18n.GetI18nManager().UpdateLang(ctx, i18n.LangCodeEnUs)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@ -385,6 +384,8 @@ func runQueryTests(t *testing.T, tests []queryTest) {
|
|||
ctx := util.NewTraceContext()
|
||||
var failedTests []string
|
||||
|
||||
initServices()
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
success := true
|
||||
|
@ -449,6 +450,10 @@ func runQueryTests(t *testing.T, tests []queryTest) {
|
|||
}
|
||||
if !actionFound {
|
||||
t.Errorf("Expected action %q not found in result actions for title %q", tt.expectedAction, result.Title)
|
||||
t.Errorf("Actual result actions:")
|
||||
for _, action := range result.Actions {
|
||||
t.Errorf(" %s", action.Name)
|
||||
}
|
||||
success = false
|
||||
}
|
||||
break
|
||||
|
|
Loading…
Reference in New Issue