mirror of
https://github.com/azaion/satellite-provider.git
synced 2026-06-22 08:01:27 +00:00
[AZ-374] Refactor C21: named GoogleMapsTiles HttpClient in DI
- Register IHttpClientFactory named client "GoogleMapsTiles" inside AddTileDownloader() with User-Agent and 100s timeout (preserves HttpClient's implicit default). - Resolve the same named client from all three CreateClient() call sites in GoogleMapsDownloaderV2 (session token, single-tile, batch-tile retry lambda) and drop the duplicated per-call UserAgent.ParseAdd setup. - Expose USER_AGENT, the client name, and the timeout as internal consts on GoogleMapsDownloaderV2 so the extension and the downloader share one source of truth. - Add AC test that builds the DI container, resolves the named client, and asserts both the User-Agent header and the timeout. - Archive AZ-374 task file: todo/ -> done/. 175 unit + 5 smoke pass. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using FluentAssertions;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Moq;
|
||||
@@ -464,6 +465,30 @@ public class TileServiceTests
|
||||
}
|
||||
}
|
||||
|
||||
public class TileDownloaderRegistrationTests
|
||||
{
|
||||
[Fact]
|
||||
public void AddTileDownloader_RegistersNamedGoogleMapsTilesHttpClient_AZ374_AC1()
|
||||
{
|
||||
// Arrange
|
||||
var services = new ServiceCollection();
|
||||
|
||||
// Act
|
||||
services.AddTileDownloader();
|
||||
using var provider = services.BuildServiceProvider();
|
||||
var factory = provider.GetRequiredService<IHttpClientFactory>();
|
||||
using var client = factory.CreateClient("GoogleMapsTiles");
|
||||
|
||||
// Assert
|
||||
client.DefaultRequestHeaders.UserAgent.Should().NotBeEmpty(
|
||||
"AZ-374 AC-1: the named GoogleMapsTiles client must carry the User-Agent set once at registration time");
|
||||
client.DefaultRequestHeaders.UserAgent.ToString()
|
||||
.Should().Contain("Mozilla/5.0", "preserves the existing outbound User-Agent for Google Maps");
|
||||
client.Timeout.Should().Be(TimeSpan.FromSeconds(100),
|
||||
"preserves the HttpClient default (100s) until C18 wires this to MapConfig");
|
||||
}
|
||||
}
|
||||
|
||||
public class GoogleMapsDownloaderZoomValidationTests
|
||||
{
|
||||
private static GoogleMapsDownloaderV2 BuildDownloader()
|
||||
|
||||
Reference in New Issue
Block a user