-
Notifications
You must be signed in to change notification settings - Fork 2
/
shortcut_test.go
47 lines (43 loc) · 985 Bytes
/
shortcut_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
40
41
42
43
44
45
46
47
//go:build windows
// +build windows
package shortcut
import (
"os"
"os/user"
"path/filepath"
"testing"
)
func TestCreateShortcut(t *testing.T) {
var err error
sc := Shortcut{
ShortcutPath: "./google.lnk",
Target: "https://google.com",
IconLocation: "%SystemRoot%\\System32\\SHELL32.dll,0",
Arguments: "",
Description: "",
Hotkey: "",
WindowStyle: "1",
WorkingDirectory: "",
}
err = Create(sc)
if err == nil {
_, err = os.Stat("./google.lnk")
if err == nil {
return
}
}
t.Errorf("CreateShortcut error: %s", err)
}
func TestCreateDesktopShortcut(t *testing.T) {
var err error
err = CreateDesktopShortcut("google", "https://google.com", "")
if err == nil {
u, _ := user.Current()
dst := filepath.Join(u.HomeDir, "Desktop", "google.lnk")
_, err = os.Stat(dst)
if err == nil {
return
}
}
t.Errorf("CreateDesktopShortcut error: %s", err)
}