(t *testing.T)
| 48 | } |
| 49 | |
| 50 | func TestParseOpenSearchHits(t *testing.T) { |
| 51 | raw := `{ |
| 52 | "hits": { |
| 53 | "hits": [ |
| 54 | {"_index": "i", "_id": "1", "_score": 2.5, "_source": {"text": "alpha", "meta": "x"}}, |
| 55 | {"_index": "i", "_id": "2", "_score": 1.0, "_source": {"content": "beta"}} |
| 56 | ] |
| 57 | } |
| 58 | }` |
| 59 | res, err := parseOpenSearchHits([]byte(raw)) |
| 60 | if err != nil { |
| 61 | t.Fatal(err) |
| 62 | } |
| 63 | if len(res.Chunks) != 2 || res.Chunks[0].Text != "alpha" || res.Chunks[1].Text != "beta" { |
| 64 | t.Fatalf("%+v", res.Chunks) |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | func TestParseMeilisearchHits(t *testing.T) { |
| 69 | raw := `{ |
nothing calls this directly
no test coverage detected