Fix syso tests. Add precommit task

This commit is contained in:
Lea Anthony
2023-09-09 16:27:51 +10:00
parent a5812578c5
commit 0cca7e9189
3 changed files with 10 additions and 52 deletions
+4
View File
@@ -125,4 +125,8 @@ tasks:
cmds:
- task: format:md
precommit:
cmds:
- go test ./...
+6 -6
View File
@@ -52,7 +52,7 @@ func TestGenerateIcon(t *testing.T) {
_, thisFile, _, _ := runtime.Caller(1)
localDir := filepath.Dir(thisFile)
// Get the path to the example icon
exampleIcon := filepath.Join(localDir, "defaults", "appicon.png")
exampleIcon := filepath.Join(localDir, "build_assets", "appicon.png")
return &IconsOptions{
Input: exampleIcon,
WindowsFilename: "appicon.ico",
@@ -94,7 +94,7 @@ func TestGenerateIcon(t *testing.T) {
_, thisFile, _, _ := runtime.Caller(1)
localDir := filepath.Dir(thisFile)
// Get the path to the example icon
exampleIcon := filepath.Join(localDir, "defaults", "appicon.png")
exampleIcon := filepath.Join(localDir, "build_assets", "appicon.png")
return &IconsOptions{
Input: exampleIcon,
MacFilename: "appicon.icns",
@@ -133,7 +133,7 @@ func TestGenerateIcon(t *testing.T) {
_, thisFile, _, _ := runtime.Caller(1)
localDir := filepath.Dir(thisFile)
// Get the path to the example icon
exampleIcon := filepath.Join(localDir, "defaults", "appicon.png")
exampleIcon := filepath.Join(localDir, "build_assets", "appicon.png")
return &IconsOptions{
Input: exampleIcon,
Sizes: "16",
@@ -181,7 +181,7 @@ func TestGenerateIcon(t *testing.T) {
_, thisFile, _, _ := runtime.Caller(1)
localDir := filepath.Dir(thisFile)
// Get the path to the example icon
exampleIcon := filepath.Join(localDir, "defaults", "appicon.png")
exampleIcon := filepath.Join(localDir, "build_assets", "appicon.png")
return &IconsOptions{
Input: exampleIcon,
}
@@ -195,7 +195,7 @@ func TestGenerateIcon(t *testing.T) {
_, thisFile, _, _ := runtime.Caller(1)
localDir := filepath.Dir(thisFile)
// Get the path to the example icon
exampleIcon := filepath.Join(localDir, "defaults", "appicon.png")
exampleIcon := filepath.Join(localDir, "build_assets", "appicon.png")
return &IconsOptions{
Input: exampleIcon,
WindowsFilename: "appicon.ico",
@@ -211,7 +211,7 @@ func TestGenerateIcon(t *testing.T) {
_, thisFile, _, _ := runtime.Caller(1)
localDir := filepath.Dir(thisFile)
// Get the path to the example icon
exampleIcon := filepath.Join(localDir, "defaults", "appicon.png")
exampleIcon := filepath.Join(localDir, "build_assets", "appicon.png")
return &IconsOptions{
Input: exampleIcon,
WindowsFilename: "appicon.ico",
-46
View File
@@ -1,8 +1,6 @@
package commands
import (
"fmt"
"os"
"path/filepath"
"runtime"
"testing"
@@ -15,50 +13,6 @@ func TestGenerateSyso(t *testing.T) {
wantErr bool
test func() error
}{
{
name: "should generate example info and manifest files when using the `example` flag",
setup: func() *SysoOptions {
return &SysoOptions{
Example: true,
}
},
wantErr: false,
test: func() error {
// the file `info.json` should be created in the current directory
// check for the existence of the file
f, err := os.Stat("info.json")
if err != nil {
return err
}
m, err := os.Stat("wails.exe.manifest")
if err != nil {
return err
}
defer func() {
err := os.Remove("info.json")
err2 := os.Remove("wails.exe.manifest")
if err != nil {
panic(err)
}
if err2 != nil {
panic(err2)
}
}()
if f.IsDir() {
return fmt.Errorf("info.json is a directory")
}
if f.Size() == 0 {
return fmt.Errorf("info.json is empty")
}
if m.IsDir() {
return fmt.Errorf("wails.exe.manifest is a directory")
}
if m.Size() == 0 {
return fmt.Errorf("wails.exe.manifest is empty")
}
return nil
},
},
{
name: "should error if manifest filename is not provided",
setup: func() *SysoOptions {