Skip to content

Commit 0476a44

Browse files
authored
[Search] Add unit tests to validate the GetIndexStatsSummary API (Azure#49081)
1 parent 0773b6e commit 0476a44

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

sdk/search/Azure.Search.Documents/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "net",
44
"TagPrefix": "net/search/Azure.Search.Documents",
5-
"Tag": "net/search/Azure.Search.Documents_7aedfaf14a"
5+
"Tag": "net/search/Azure.Search.Documents_d95b07f81b"
66
}

sdk/search/Azure.Search.Documents/tests/SearchIndexClientTests.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,35 @@ public async Task GetServiceStatistics()
131131
Assert.NotZero(response.Value.Counters.IndexCounter.Usage);
132132
}
133133

134+
[Test]
135+
[ServiceVersion(Min = SearchClientOptions.ServiceVersion.V2025_03_01_Preview)]
136+
public async Task GetIndexStatsSummary()
137+
{
138+
await using SearchResources resources = await SearchResources.GetSharedHotelsIndexAsync(this);
139+
140+
SearchIndexClient client = resources.GetIndexClient();
141+
Response<ListIndexStatsSummary> response = await client.GetIndexStatsSummaryAsync();
142+
Assert.AreEqual(200, response.GetRawResponse().Status);
143+
Assert.IsNotNull(response.Value);
144+
Assert.IsNotNull(response.Value.IndexesStatistics);
145+
Assert.AreEqual(1, response.Value.IndexesStatistics.Count);
146+
Assert.AreEqual(resources.IndexName, response.Value.IndexesStatistics[0].Name);
147+
}
148+
149+
[Test]
150+
[ServiceVersion(Min = SearchClientOptions.ServiceVersion.V2025_03_01_Preview)]
151+
public async Task GetIndexStatsSummaryWithNoIndexes()
152+
{
153+
await using SearchResources resources = SearchResources.CreateWithNoIndexes(this);
154+
155+
SearchIndexClient client = resources.GetIndexClient();
156+
Response<ListIndexStatsSummary> response = await client.GetIndexStatsSummaryAsync();
157+
Assert.AreEqual(200, response.GetRawResponse().Status);
158+
Assert.IsNotNull(response.Value);
159+
Assert.IsNotNull(response.Value.IndexesStatistics);
160+
Assert.AreEqual(0, response.Value.IndexesStatistics.Count);
161+
}
162+
134163
[Test]
135164
[SyncOnly]
136165
public void CreateIndexParameterValidation()

0 commit comments

Comments
 (0)