5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-04 02:20:47 +08:00

Fix tests

This commit is contained in:
Lea Anthony 2024-08-04 21:28:15 +10:00
parent cd3b561623
commit 1cba1416a1
7 changed files with 13 additions and 14 deletions

View File

@ -2,6 +2,7 @@ package commands
import (
"fmt"
"github.com/pkg/errors"
"os"
"runtime"
@ -42,7 +43,10 @@ func GenerateSyso(options *SysoOptions) (err error) {
return err
}
defer func() {
err = iconFile.Close()
err2 := iconFile.Close()
if err == nil {
err = errors.Wrap(err, "error closing icon file: "+err2.Error())
}
}()
ico, err := winres.LoadICO(iconFile)
if err != nil {

View File

@ -125,14 +125,10 @@ func TestGenerateSyso(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
options := tt.setup()
err := GenerateSyso(options)
if (err != nil) != tt.wantErr {
if (err == nil) && tt.wantErr {
t.Errorf("GenerateSyso() error = %v, wantErr %v", err, tt.wantErr)
return
}
if (err != nil) && tt.wantErr {
println(err.Error())
return
}
if tt.test != nil {
if err := tt.test(); err != nil {
t.Errorf("GenerateSyso() test error = %v", err)

View File

@ -348,7 +348,7 @@ func cleanup() {
func (a *App) logPlatformInfo() {
info, err := operatingsystem.Info()
if err != nil {
a.error("Error getting OS info", "error", err.Error())
a.error("Error getting OS info: %s", err.Error())
return
}
@ -360,7 +360,6 @@ func (a *App) platformEnvironment() map[string]any {
return map[string]any{}
}
func fatalHandler(errFunc func(error)) {
return
return
}

View File

@ -199,7 +199,7 @@ func parseAccelerator(shortcut string) (*accelerator, error) {
if !validKey {
return nil, fmt.Errorf("'%s' is not a valid key", component)
}
result.Key = processedKey
result.Key = strings.ToLower(processedKey)
continue
}

View File

@ -14,8 +14,8 @@ func TestMenuItem_GetAccelerator(t *testing.T) {
}{
{
name: "Get existing accelerator",
menuItem: application.NewMenuItem("Item 1").SetAccelerator("Ctrl+A"),
expectedAcc: "ctrl+a",
menuItem: application.NewMenuItem("Item 1").SetAccelerator("ctrl+a"),
expectedAcc: "Ctrl+A",
},
{
name: "Get non-existing accelerator",

View File

@ -53,7 +53,7 @@ func systrayClickCallback(id C.long, buttonID C.int) {
// Get the system tray
systemTray := systemTrayMap[uint(id)]
if systemTray == nil {
globalApplication.error("system tray not found", "id", id)
globalApplication.error("system tray not found: %v", id)
return
}
systemTray.processClick(button(buttonID))

View File

@ -58,4 +58,4 @@ require (
gopkg.in/warnings.v0 v0.1.2 // indirect
)
replace github.com/wailsapp/wails/v3 => ../..
replace github.com/wailsapp/wails/v3 => ../../..