~hristoast/wem

ref: 7b62435662a80e0a30f1b81042e7f4198db740b6 wem/cfg/main_test.go -rw-r--r-- 1.9 KiB
7b624356Hristos N. Triantafillou Set WINE_LARGE_ADDRESS_AWARE=1 when DXVK is in use (#10) 1 year, 4 months ago
                                                                                
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
66
67
68
69
70
71
72
73
74
75
76
77
78
package cfg_test

import (
	"io/ioutil"
	"log"
	"os"
	"path/filepath"
	"testing"

	"git.sr.ht/~hristoast/wem/cfg"
)

func TestCfg(t *testing.T) {
	// Setup
	dir, err := ioutil.TempDir("", "wemTestCfg")
	if err != nil {
		log.Fatal(err)
	}
	os.Setenv("HOME", dir)

	t.Run("ApplyArgs: cacheDir", func(t *testing.T) {
		c, _ := cfg.GetConfig()
		c.ApplyArgs("applied!", c.ProtonDir, c.WineBuildDir, c.WineEnvDir, c.WineSrcDir)
		if c.CacheDir != "applied!" {
			t.Errorf("got: %s; want: %s", c.CacheDir, "applied!")
		}
	})

	t.Run("ApplyArgs: protonDir", func(t *testing.T) {
		c, _ := cfg.GetConfig()
		c.ApplyArgs(c.CacheDir, "applied!", c.WineBuildDir, c.WineEnvDir, c.WineSrcDir)
		if c.ProtonDir != "applied!" {
			t.Errorf("got: %s; want: %s", c.ProtonDir, "applied!")
		}
	})

	t.Run("ApplyArgs: wineBuildDir", func(t *testing.T) {
		c, _ := cfg.GetConfig()
		c.ApplyArgs(c.CacheDir, c.ProtonDir, "applied!", c.WineEnvDir, c.WineSrcDir)
		if c.WineBuildDir != "applied!" {
			t.Errorf("got: %s; want: %s", c.WineBuildDir, "applied!")
		}
	})

	t.Run("ApplyArgs: wineEnvDir", func(t *testing.T) {
		c, _ := cfg.GetConfig()
		c.ApplyArgs(c.CacheDir, c.ProtonDir, c.WineBuildDir, "applied!", c.WineSrcDir)
		if c.WineEnvDir != "applied!" {
			t.Errorf("got: %s; want: %s", c.WineEnvDir, "applied!")
		}
	})

	t.Run("ApplyArgs: wineSrcDir", func(t *testing.T) {
		c, _ := cfg.GetConfig()
		c.ApplyArgs(c.CacheDir, c.ProtonDir, c.WineBuildDir, c.WineEnvDir, "applied!")
		if c.WineSrcDir != "applied!" {
			t.Errorf("got: %s; want: %s", c.WineSrcDir, "applied!")
		}
	})

	t.Run("Validate", func(t *testing.T) {
		c, _ := cfg.GetConfig()
		validate := c.Validate()
		if validate != nil {
			t.Errorf("got: %v; want: %v", validate, nil)
		}
	})

	t.Run("CfgDir", func(t *testing.T) {
		cfgDir := cfg.CfgDir()
		expected := filepath.Join(dir, ".config", "wem")
		if cfgDir != expected {
			t.Errorf("got: %s; want: %s", cfgDir, expected)
		}
	})

	os.RemoveAll(dir)
}