Skip to content

Commit 456a4ea

Browse files
test(audience-sdk): centralise LogTests inputs and reference Log.Prefix
LogTests had inline literals for the Log.Debug / Log.Warn inputs ("silent", "hello", "something off"), the prefix substring asserted on emitted lines ("[ImmutableAudience]"), and the warn marker ("WARN"). Adds four file-local consts (SilentDebugInput, EnabledDebugInput, WarnInput, WarnMarker) at the top of the fixture and migrates the six call sites. The prefix assertion now references Log.Prefix, the SDK's existing const for the same string, so a SDK-side prefix rename automatically propagates. The "WARN" substring is kept as a local marker rather than slicing Log.WarnPrefix; "[ImmutableAudience] WARN:" includes punctuation the assertion does not require. A direct WARN constant matches the test's actual intent ("the warn pipeline includes WARN somewhere"). Per the user's "everything random goes in a constant" stance. Follow-up to SDK-272 (centralisation of duplicated literals).
1 parent af7a0c0 commit 456a4ea

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

src/Packages/Audience/Tests/Runtime/Utility/LogTests.cs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ namespace Immutable.Audience.Tests
66
[TestFixture]
77
internal class LogTests
88
{
9+
// Inputs to Log.Debug / Log.Warn used across the fixture.
10+
private const string SilentDebugInput = "silent";
11+
private const string EnabledDebugInput = "hello";
12+
private const string WarnInput = "something off";
13+
14+
// Substring marker that Log.Warn injects between the prefix and the user message.
15+
private const string WarnMarker = "WARN";
16+
917
private List<string> _captured;
1018

1119
[SetUp]
@@ -28,7 +36,7 @@ public void Debug_WhenDisabled_EmitsNothing()
2836
{
2937
Log.Enabled = false;
3038

31-
Log.Debug("silent");
39+
Log.Debug(SilentDebugInput);
3240

3341
Assert.AreEqual(0, _captured.Count);
3442
}
@@ -38,23 +46,23 @@ public void Debug_WhenEnabled_EmitsWithPrefix()
3846
{
3947
Log.Enabled = true;
4048

41-
Log.Debug("hello");
49+
Log.Debug(EnabledDebugInput);
4250

4351
Assert.AreEqual(1, _captured.Count);
44-
StringAssert.StartsWith("[ImmutableAudience]", _captured[0]);
45-
StringAssert.Contains("hello", _captured[0]);
52+
StringAssert.StartsWith(Log.Prefix, _captured[0]);
53+
StringAssert.Contains(EnabledDebugInput, _captured[0]);
4654
}
4755

4856
[Test]
4957
public void Warn_AlwaysEmits_EvenWhenDisabled()
5058
{
5159
Log.Enabled = false;
5260

53-
Log.Warn("something off");
61+
Log.Warn(WarnInput);
5462

5563
Assert.AreEqual(1, _captured.Count);
56-
StringAssert.Contains("WARN", _captured[0]);
57-
StringAssert.Contains("something off", _captured[0]);
64+
StringAssert.Contains(WarnMarker, _captured[0]);
65+
StringAssert.Contains(WarnInput, _captured[0]);
5866
}
5967
}
6068
}

0 commit comments

Comments
 (0)