forked from josephspurrier/goversioninfo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathicon_test.go
39 lines (34 loc) · 808 Bytes
/
icon_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package goversioninfo
import (
"io/ioutil"
"os"
"path/filepath"
"runtime"
"testing"
)
func TestIconReleaseFileHandle(t *testing.T) {
icoPath := "testdata/resource/icon.ico"
icoPath2 := "testdata/resource/icon2.ico"
tmpdir, err := ioutil.TempDir("", "resource")
if err != nil {
t.Error("Could not create temp dir", err)
}
defer os.RemoveAll(tmpdir)
outPath := filepath.Join(tmpdir, "resource.syso")
vi := &VersionInfo{}
vi.IconPath = icoPath
vi.Build()
vi.Walk()
err = vi.WriteSyso(outPath, runtime.GOARCH)
if err != nil {
t.Errorf("Unexpected error writing resource: %v", err)
}
err = os.Rename(icoPath, icoPath2)
if err != nil {
t.Errorf("Error renaming icon: %v", err)
}
err = os.Rename(icoPath2, icoPath)
if err != nil {
t.Errorf("Error restoring icon: %v", err)
}
}