diff --git a/reliability/single-fit/logs/src/test/kotlin/com/datadog/android/logs/integration/LoggerTest.kt b/reliability/single-fit/logs/src/test/kotlin/com/datadog/android/logs/integration/LoggerTest.kt index 9ba8e5a853..d80b51d3c0 100644 --- a/reliability/single-fit/logs/src/test/kotlin/com/datadog/android/logs/integration/LoggerTest.kt +++ b/reliability/single-fit/logs/src/test/kotlin/com/datadog/android/logs/integration/LoggerTest.kt @@ -862,6 +862,34 @@ class LoggerTest { assertThat(event0.getString(fakeAttributeKey)).isEqualTo(fakeAttributeValue2) } + @RepeatedTest(16) + fun `M send log without attribute W Logs#addAttribute() + Logs#removeAttribute() + Logger#log()`( + @StringForgery fakeAttributeKey: String, + @StringForgery fakeAttributeValue: String, + @StringForgery fakeMessage: String, + @IntForgery(Log.VERBOSE, 10) fakeLevel: Int + ) { + // Given + val testedLogger = Logger.Builder(stubSdkCore).build() + + // When + Logs.addAttribute(fakeAttributeKey, fakeAttributeValue, stubSdkCore) + Logs.removeAttribute(fakeAttributeKey, stubSdkCore) + testedLogger.log(fakeLevel, fakeMessage) + + // Then + val eventsWritten = stubSdkCore.eventsWritten(Feature.LOGS_FEATURE_NAME) + assertThat(eventsWritten).hasSize(1) + val event0 = JsonParser.parseString(eventsWritten[0].eventData) as JsonObject + assertThat(event0.getString("ddtags")).contains("env:" + stubSdkCore.getDatadogContext().env) + assertThat(event0.getString("ddtags")).contains("version:" + stubSdkCore.getDatadogContext().version) + assertThat(event0.getString("ddtags")).contains("variant:" + stubSdkCore.getDatadogContext().variant) + assertThat(event0.getString("service")).isEqualTo(stubSdkCore.getDatadogContext().service) + assertThat(event0.getString("message")).isEqualTo(fakeMessage) + assertThat(event0.getString("status")).isEqualTo(LEVEL_NAMES[fakeLevel]) + assertThat(event0.getString(fakeAttributeKey)).isNull() + } + @RepeatedTest(16) fun `M send log with overridden custom attribute W Logs#addAttribute() + Logger#addAttribute() + Logger#log()`( @StringForgery fakeAttributeKey: String, @@ -920,7 +948,7 @@ class LoggerTest { } @RepeatedTest(16) - fun `M send log with updated custom attribute W Logger#addAttribute() + Logger#removeAttribute() + Logger#log()`( + fun `M send log without attribute W Logger#addAttribute() + Logger#removeAttribute() + Logger#log()`( @StringForgery fakeAttributeKey: String, @StringForgery fakeAttributeValue: String, @StringForgery fakeMessage: String,