-
Notifications
You must be signed in to change notification settings - Fork 6
/
platform_linux_test.go
59 lines (48 loc) · 1.06 KB
/
platform_linux_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
48
49
50
51
52
53
54
55
56
57
58
package main
import (
"errors"
"os"
"testing"
)
func TestGetDefaultLibraryInWsl(t *testing.T) {
invocation := 1
fakeExecCmdFunc := func(_ string) (string, error) {
switch (invocation) {
case 1:
invocation++
return "C:", nil
case 2:
invocation++
return "\\Users\\SomeUser", nil
default:
return "", errors.New("function called too often")
}
}
os.Setenv("WSLENV", "FOO")
result, err := defaultLibraryPathInternal(fakeExecCmdFunc)
if (err != nil) {
t.Fail()
t.Logf("function return error")
}
expected := "/mnt/c/Users/SomeUser/Music/iTunes/iTunes Music Library.xml"
if (result != expected) {
t.Fail()
t.Logf("expected %v, got %v", expected, result)
}
}
func TestGetDefaultLibraryInLinux(t *testing.T) {
stubFunc := func(_ string) (string, error) {
return "", nil
}
os.Unsetenv("WSLENV")
result, err := defaultLibraryPathInternal(stubFunc)
if (err != nil) {
t.Fail()
t.Logf("function return error")
}
expected := "/mnt/itunes"
if (result != expected) {
t.Fail()
t.Logf("expected %v, got %v", expected, result)
}
}