Skip to content

Commit

Permalink
refactor(test): improve test setup and error reporting
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
qianlifeng committed Feb 20, 2025
1 parent f946e21 commit 2a6c159
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
13 changes: 0 additions & 13 deletions ai_prompt_i18n.txt

This file was deleted.

5 changes: 5 additions & 0 deletions git-commit.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
description:
globs:
---

11 changes: 8 additions & 3 deletions wox.core/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ func TestCalculatorTime(t *testing.T) {
runQueryTests(t, tests)
}

func init() {
func initServices() {
ctx := context.Background()

// Initialize location
Expand All @@ -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)
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2a6c159

Please sign in to comment.