Skip to content

Commit 85d4841

Browse files
test(audience-sdk): centralise publishable-key fixtures across transport, stress, and offline tests
Three test files had inline publishable-key fixtures with no intra-test reason for diverging from the canonical TestDefaults.PublishableKey: - ThreadSafetyStressTests:48 used "pk_imapik-test-stress" - OfflineResilienceTests:47 used "pk_imapik-test-key" Both fall under "any test-prefix key, content does not matter". Migrated to TestDefaults.PublishableKey. HttpTransportTests:162 used "pk_imapik-prodkey" specifically to verify a non-test-prefix key resolves to ProductionBaseUrl. The test cannot use TestDefaults.PublishableKey since that one IS test-prefixed. Added a file-local ProdPublishableKey const alongside the existing response-body fixtures and migrated the one usage. The const carries a comment explaining the prefix constraint. Per the user's "everything random goes in a constant" stance. Follow-up to SDK-272 (centralisation of duplicated literals).
1 parent ddd9d77 commit 85d4841

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

src/Packages/Audience/Tests/Runtime/OfflineResilienceTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage reques
4444

4545
private AudienceConfig MakeConfig() => new AudienceConfig
4646
{
47-
PublishableKey = "pk_imapik-test-key",
47+
PublishableKey = TestDefaults.PublishableKey,
4848
Consent = ConsentLevel.Anonymous,
4949
PersistentDataPath = _testDir,
5050
FlushIntervalSeconds = TestDefaults.FlushIntervalSeconds,

src/Packages/Audience/Tests/Runtime/ThreadSafetyStressTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage reques
4545
private AudienceConfig MakeConfig(ConsentLevel consent = ConsentLevel.Full) =>
4646
new AudienceConfig
4747
{
48-
PublishableKey = "pk_imapik-test-stress",
48+
PublishableKey = TestDefaults.PublishableKey,
4949
Consent = consent,
5050
PersistentDataPath = _testDir,
5151
FlushIntervalSeconds = TestDefaults.FlushIntervalSeconds,

src/Packages/Audience/Tests/Runtime/Transport/HttpTransportTests.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ namespace Immutable.Audience.Tests
1717
[TestFixture]
1818
internal class HttpTransportTests
1919
{
20+
// Non-test-prefix publishable key. Must not carry pk_imapik-test- (asserts production BaseUrl).
21+
private const string ProdPublishableKey = "pk_imapik-prodkey";
22+
2023
// Response body fixtures.
2124
private const string MalformedResponseBody = "not-json";
2225
private const string EmptyJsonObjectBody = "{}";
@@ -156,7 +159,7 @@ public async Task SendBatchAsync_200_UsesCorrectUrlForProdKey()
156159
HttpRequestMessage? captured = null;
157160
var handler = new MockHandler(HttpStatusCode.OK, $"{{\"accepted\":1,\"{ResponseFields.Rejected}\":0}}",
158161
onRequest: req => captured = req);
159-
using var transport = new HttpTransport(_store, "pk_imapik-prodkey", handler: handler);
162+
using var transport = new HttpTransport(_store, ProdPublishableKey, handler: handler);
160163

161164
await transport.SendBatchAsync();
162165

0 commit comments

Comments
 (0)