MCPcopy Index your code
hub / github.com/cheat/cheat / TestFilterSuccess

Function TestFilterSuccess

internal/cheatpath/filter_test.go:9–35  ·  view source on GitHub ↗

TestFilterSuccess asserts that the proper cheatpath is returned when the requested cheatpath exists

(t *testing.T)

Source from the content-addressed store, hash-verified

7// TestFilterSuccess asserts that the proper cheatpath is returned when the
8// requested cheatpath exists
9func TestFilterSuccess(t *testing.T) {
10
11 // init cheatpaths
12 paths := []Path{
13 Path{Name: "foo"},
14 Path{Name: "bar"},
15 Path{Name: "baz"},
16 }
17
18 // filter the paths
19 paths, err := Filter(paths, "bar")
20 if err != nil {
21 t.Errorf("failed to filter paths: %v", err)
22 }
23
24 // assert that the expected path was returned
25 if len(paths) != 1 {
26 t.Errorf(
27 "failed to return correct path count: want: 1, got: %d",
28 len(paths),
29 )
30 }
31
32 if paths[0].Name != "bar" {
33 t.Errorf("failed to return correct path: want: bar, got: %s", paths[0].Name)
34 }
35}
36
37// TestFilterFailure asserts that an error is returned when a non-existent
38// cheatpath is requested

Callers

nothing calls this directly

Calls 1

FilterFunction · 0.70

Tested by

no test coverage detected