TestFilterSuccess asserts that the proper cheatpath is returned when the requested cheatpath exists
(t *testing.T)
| 7 | // TestFilterSuccess asserts that the proper cheatpath is returned when the |
| 8 | // requested cheatpath exists |
| 9 | func 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 |