(t *testing.T)
| 10 | ) |
| 11 | |
| 12 | func Test_parseIndices(t *testing.T) { |
| 13 | tests := []struct { |
| 14 | name string |
| 15 | query string |
| 16 | expected []uint64 |
| 17 | expectError *httpError |
| 18 | }{ |
| 19 | { |
| 20 | name: "happy path with comma-separated indices", |
| 21 | query: "indices=0,1,2", |
| 22 | expected: []uint64{0, 1, 2}, |
| 23 | expectError: nil, |
| 24 | }, |
| 25 | { |
| 26 | name: "happy path with repeated indices parameter", |
| 27 | query: "indices=0&indices=1&indices=2", |
| 28 | expected: []uint64{0, 1, 2}, |
| 29 | expectError: nil, |
| 30 | }, |
| 31 | { |
| 32 | name: "happy path with duplicate indices within bound and other query parameters ignored", |
| 33 | query: "indices=1&indices=2&indices=1&indices=3&bar=bar", |
| 34 | expected: []uint64{1, 2, 3}, |
| 35 | expectError: nil, |
| 36 | }, |
| 37 | { |
| 38 | name: "happy path with comma-separated indices within bound and other query parameters ignored", |
| 39 | query: "indices=1,2,3,3&bar=bar", |
| 40 | expected: []uint64{1, 2, 3}, |
| 41 | expectError: nil, |
| 42 | }, |
| 43 | { |
| 44 | name: "invalid indices with comma-separated indices", |
| 45 | query: "indices=1,abc,2&bar=bar", |
| 46 | expected: nil, |
| 47 | expectError: newBadRequestError("requested blob indices [abc] are invalid"), |
| 48 | }, |
| 49 | { |
| 50 | name: "invalid indices with repeated indices", |
| 51 | query: "indices=0&indices=abc&indices=2", |
| 52 | expected: nil, |
| 53 | expectError: newBadRequestError("requested blob indices [abc] are invalid"), |
| 54 | }, |
| 55 | { |
| 56 | name: "out of bounds indices throws error", |
| 57 | query: "indices=2&indices=7", |
| 58 | expected: nil, |
| 59 | expectError: newBadRequestError("requested blob indices [7] are invalid"), |
| 60 | }, |
| 61 | { |
| 62 | name: "negative indices", |
| 63 | query: "indices=-1", |
| 64 | expected: nil, |
| 65 | expectError: newBadRequestError("requested blob indices [-1] are invalid"), |
| 66 | }, |
| 67 | } |
| 68 | |
| 69 | for _, tt := range tests { |
nothing calls this directly
no test coverage detected