mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-07 07:20:58 +08:00
Fix tests
This commit is contained in:
parent
cd3b561623
commit
1cba1416a1
@ -2,6 +2,7 @@ package commands
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/pkg/errors"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
@ -42,7 +43,10 @@ func GenerateSyso(options *SysoOptions) (err error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer func() {
|
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)
|
ico, err := winres.LoadICO(iconFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -125,14 +125,10 @@ func TestGenerateSyso(t *testing.T) {
|
|||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
options := tt.setup()
|
options := tt.setup()
|
||||||
err := GenerateSyso(options)
|
err := GenerateSyso(options)
|
||||||
if (err != nil) != tt.wantErr {
|
if (err == nil) && tt.wantErr {
|
||||||
t.Errorf("GenerateSyso() error = %v, wantErr %v", err, tt.wantErr)
|
t.Errorf("GenerateSyso() error = %v, wantErr %v", err, tt.wantErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (err != nil) && tt.wantErr {
|
|
||||||
println(err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if tt.test != nil {
|
if tt.test != nil {
|
||||||
if err := tt.test(); err != nil {
|
if err := tt.test(); err != nil {
|
||||||
t.Errorf("GenerateSyso() test error = %v", err)
|
t.Errorf("GenerateSyso() test error = %v", err)
|
||||||
|
@ -348,7 +348,7 @@ func cleanup() {
|
|||||||
func (a *App) logPlatformInfo() {
|
func (a *App) logPlatformInfo() {
|
||||||
info, err := operatingsystem.Info()
|
info, err := operatingsystem.Info()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.error("Error getting OS info", "error", err.Error())
|
a.error("Error getting OS info: %s", err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -360,7 +360,6 @@ func (a *App) platformEnvironment() map[string]any {
|
|||||||
return map[string]any{}
|
return map[string]any{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func fatalHandler(errFunc func(error)) {
|
func fatalHandler(errFunc func(error)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -199,7 +199,7 @@ func parseAccelerator(shortcut string) (*accelerator, error) {
|
|||||||
if !validKey {
|
if !validKey {
|
||||||
return nil, fmt.Errorf("'%s' is not a valid key", component)
|
return nil, fmt.Errorf("'%s' is not a valid key", component)
|
||||||
}
|
}
|
||||||
result.Key = processedKey
|
result.Key = strings.ToLower(processedKey)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,8 +14,8 @@ func TestMenuItem_GetAccelerator(t *testing.T) {
|
|||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "Get existing accelerator",
|
name: "Get existing accelerator",
|
||||||
menuItem: application.NewMenuItem("Item 1").SetAccelerator("Ctrl+A"),
|
menuItem: application.NewMenuItem("Item 1").SetAccelerator("ctrl+a"),
|
||||||
expectedAcc: "ctrl+a",
|
expectedAcc: "Ctrl+A",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Get non-existing accelerator",
|
name: "Get non-existing accelerator",
|
||||||
|
@ -53,7 +53,7 @@ func systrayClickCallback(id C.long, buttonID C.int) {
|
|||||||
// Get the system tray
|
// Get the system tray
|
||||||
systemTray := systemTrayMap[uint(id)]
|
systemTray := systemTrayMap[uint(id)]
|
||||||
if systemTray == nil {
|
if systemTray == nil {
|
||||||
globalApplication.error("system tray not found", "id", id)
|
globalApplication.error("system tray not found: %v", id)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
systemTray.processClick(button(buttonID))
|
systemTray.processClick(button(buttonID))
|
||||||
|
@ -58,4 +58,4 @@ require (
|
|||||||
gopkg.in/warnings.v0 v0.1.2 // indirect
|
gopkg.in/warnings.v0 v0.1.2 // indirect
|
||||||
)
|
)
|
||||||
|
|
||||||
replace github.com/wailsapp/wails/v3 => ../..
|
replace github.com/wailsapp/wails/v3 => ../../..
|
||||||
|
Loading…
Reference in New Issue
Block a user