MCPcopy
hub / github.com/cheat/cheat / TestValidatePathsCheatConfigPath

Function TestValidatePathsCheatConfigPath

internal/config/paths_test.go:154–184  ·  view source on GitHub ↗

TestValidatePathsCheatConfigPath asserts that the proper config path is returned when `CHEAT_CONFIG_PATH` is explicitly specified.

(t *testing.T)

Source from the content-addressed store, hash-verified

152// TestValidatePathsCheatConfigPath asserts that the proper config path is
153// returned when `CHEAT_CONFIG_PATH` is explicitly specified.
154func TestValidatePathsCheatConfigPath(t *testing.T) {
155
156 // mock the user's home directory
157 home := "/home/foo"
158
159 // mock some envvars
160 envvars := map[string]string{
161 "XDG_CONFIG_HOME": "/home/bar",
162 "CHEAT_CONFIG_PATH": "/home/baz/conf.yml",
163 }
164
165 // get the paths for the platform
166 paths, err := Paths("linux", home, envvars)
167 if err != nil {
168 t.Errorf("paths returned an error: %v", err)
169 }
170
171 // specify the expected output
172 want := []string{
173 "/home/baz/conf.yml",
174 }
175
176 // assert that output matches expectations
177 if !reflect.DeepEqual(paths, want) {
178 t.Errorf(
179 "failed to return expected paths: want:\n%s, got:\n%s",
180 spew.Sdump(want),
181 spew.Sdump(paths),
182 )
183 }
184}

Callers

nothing calls this directly

Calls 1

PathsFunction · 0.70

Tested by

no test coverage detected