File: userdirs_test.go

package info (click to toggle)
golang-github-rkoesters-xdg 0.0~git20181125.edd15b8-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 220 kB
  • sloc: makefile: 5
file content (56 lines) | stat: -rw-r--r-- 1,045 bytes parent folder | download
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
package userdirs

import (
	"os/exec"
	"strings"
	"testing"
)

// XdgUserDir runs the xdg-user-dir command with the given argument.
func XdgUserDir(s string) string {
	out, err := exec.Command("xdg-user-dir", s).Output()
	if err != nil {
		panic(err)
	}
	return strings.TrimSpace(string(out))
}

func doTest(t *testing.T, s1, s2 string) {
	t.Log(s1)
	t.Log(s2)
	if s1 != s2 {
		t.Fail()
	}
}

func TestDesktop(t *testing.T) {
	doTest(t, Desktop, XdgUserDir("DESKTOP"))
}

func TestDocuments(t *testing.T) {
	doTest(t, Documents, XdgUserDir("DOCUMENTS"))
}

func TestDownload(t *testing.T) {
	doTest(t, Download, XdgUserDir("DOWNLOAD"))
}

func TestMusic(t *testing.T) {
	doTest(t, Music, XdgUserDir("MUSIC"))
}

func TestPictures(t *testing.T) {
	doTest(t, Pictures, XdgUserDir("PICTURES"))
}

func TestPublicShare(t *testing.T) {
	doTest(t, PublicShare, XdgUserDir("PUBLICSHARE"))
}

func TestTemplates(t *testing.T) {
	doTest(t, Templates, XdgUserDir("TEMPLATES"))
}

func TestVideos(t *testing.T) {
	doTest(t, Videos, XdgUserDir("VIDEOS"))
}