public async Task Query_WhenInvalidIndexName_Returns403() { ConfigContextBase.SearchUris.Add(new FailureCountingUri("http://10.141.151.101:8091/")); var fakeMessageHandler = new FakeMessageHandler { StatusCode = HttpStatusCode.Forbidden, Content = new StringContent("rest_auth: preparePerm, err: index not found ") }; var client = new SearchClient(new HttpClient(fakeMessageHandler), new SearchDataMapper()); var response = await client.QueryAsync(new SearchQuery { Index = "indexdoesnotexist", Query = new MatchQuery("foo") }); Assert.IsTrue(response.Errors.First().Contains("rest_auth: preparePerm, err: index not found")); }
public async Task Query_WhenInvalidUri_Returns404() { ConfigContextBase.SearchUris.Add(new FailureCountingUri("http://10.141.151.101:8091/")); var fakeMessageHandler = new FakeMessageHandler { StatusCode = HttpStatusCode.NotFound, Content = new StringContent("Requested resource not found. ") }; var client = new SearchClient(new HttpClient(fakeMessageHandler), new SearchDataMapper()); var response = await client.QueryAsync(new SearchQuery { Index = "indexdoesnotexist", Query = new MatchQuery("foo") }); Assert.IsTrue(response.Exception.Message.Contains("404")); }
public async Task Query_WhenInvalidUri_MaxScoreIsZero() { ConfigContextBase.SearchUris.Add(new FailureCountingUri("http://10.141.151.101:8091/")); var fakeMessageHandler = new FakeMessageHandler { StatusCode = HttpStatusCode.NotFound, Content = new StringContent("Requested resource not found. ") }; var client = new SearchClient(new HttpClient(fakeMessageHandler), new SearchDataMapper()); var response = await client.QueryAsync(new SearchQuery { Index = "indexdoesnotexist", Query = new MatchQuery("foo") }); Assert.AreEqual(0, response.Metrics.MaxScore); }