File: xdg_linux_test.go

package info (click to toggle)
golang-github-openpeedeep-xdg 0.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 116 kB
  • sloc: makefile: 2
file content (65 lines) | stat: -rw-r--r-- 1,551 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
57
58
59
60
61
62
63
64
65
// +build linux

// Copyright (c) 2017, OpenPeeDeeP. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package xdg

import (
	"os"
	"testing"

	"github.com/stretchr/testify/assert"
)

func TestDefaultDataHome(t *testing.T) {
	setDefaulter(new(osDefaulter))
	assert := assert.New(t)
	homeDir := "/some/path"
	expected := homeDir + "/.local/share"
	os.Setenv("HOME", homeDir) // nolint: errcheck

	actual := defaulter.defaultDataHome()
	assert.Equal(expected, actual)
}

func TestDefaultDataDirs(t *testing.T) {
	setDefaulter(new(osDefaulter))
	assert := assert.New(t)
	expected := []string{"/usr/local/share/", "/usr/share/"}

	actual := defaulter.defaultDataDirs()
	assert.Equal(expected, actual)
}

func TestDefaultConfigHome(t *testing.T) {
	setDefaulter(new(osDefaulter))
	assert := assert.New(t)
	homeDir := "/some/path"
	expected := homeDir + "/.config"
	os.Setenv("HOME", homeDir) // nolint: errcheck

	actual := defaulter.defaultConfigHome()
	assert.Equal(expected, actual)
}

func TestDefaultConfigDirs(t *testing.T) {
	setDefaulter(new(osDefaulter))
	assert := assert.New(t)
	expected := []string{"/etc/xdg"}

	actual := defaulter.defaultConfigDirs()
	assert.Equal(expected, actual)
}

func TestDefaultCacheHome(t *testing.T) {
	setDefaulter(new(osDefaulter))
	assert := assert.New(t)
	homeDir := "/some/path"
	expected := homeDir + "/.cache"
	os.Setenv("HOME", homeDir) // nolint: errcheck

	actual := defaulter.defaultCacheHome()
	assert.Equal(expected, actual)
}