TestValidatePathsWindows asserts that the proper config paths are returned on Windows platforms
(t *testing.T)
| 108 | // TestValidatePathsWindows asserts that the proper config paths are returned |
| 109 | // on Windows platforms |
| 110 | func TestValidatePathsWindows(t *testing.T) { |
| 111 | |
| 112 | // mock the user's home directory |
| 113 | home := "not-used-on-windows" |
| 114 | |
| 115 | // mock some envvars |
| 116 | envvars := map[string]string{ |
| 117 | "APPDATA": filepath.Join("C:", "apps"), |
| 118 | "PROGRAMDATA": filepath.Join("C:", "programs"), |
| 119 | } |
| 120 | |
| 121 | // get the paths for the platform |
| 122 | paths, err := Paths("windows", home, envvars) |
| 123 | if err != nil { |
| 124 | t.Errorf("paths returned an error: %v", err) |
| 125 | } |
| 126 | |
| 127 | // specify the expected output |
| 128 | want := []string{ |
| 129 | filepath.Join("C:", "apps", "cheat", "conf.yml"), |
| 130 | filepath.Join("C:", "programs", "cheat", "conf.yml"), |
| 131 | } |
| 132 | |
| 133 | // assert that output matches expectations |
| 134 | if !reflect.DeepEqual(paths, want) { |
| 135 | t.Errorf( |
| 136 | "failed to return expected paths: want:\n%s, got:\n%s", |
| 137 | spew.Sdump(want), |
| 138 | spew.Sdump(paths), |
| 139 | ) |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | // TestValidatePathsUnsupported asserts that an error is returned on |
| 144 | // unsupported platforms |