From 81b75a5f26cecb425269aea4f25be1f493ecce18 Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Thu, 23 Jul 2020 11:17:25 +0200 Subject: [PATCH] ref: fix test linting --- .../io/sentry/core/DiagnosticLoggerTest.kt | 32 +++++++++---------- ...CachedEventFireAndForgetIntegrationTest.kt | 6 ++-- .../java/io/sentry/core/SentryClientTest.kt | 13 -------- 3 files changed, 19 insertions(+), 32 deletions(-) diff --git a/sentry-core/src/test/java/io/sentry/core/DiagnosticLoggerTest.kt b/sentry-core/src/test/java/io/sentry/core/DiagnosticLoggerTest.kt index f30280854..110a5e23d 100644 --- a/sentry-core/src/test/java/io/sentry/core/DiagnosticLoggerTest.kt +++ b/sentry-core/src/test/java/io/sentry/core/DiagnosticLoggerTest.kt @@ -39,7 +39,7 @@ class DiagnosticLoggerTest { @Test fun `when debug is true and level is set to null, a call to log does not throw`() { - fixture.options!!.setDiagnosticLevel(null) + fixture.options.setDiagnosticLevel(null) fixture.getSut().log(SentryLevel.DEBUG, expectedMessage) } @@ -61,7 +61,7 @@ class DiagnosticLoggerTest { @Test fun `when debug is true and option level is info, a call to log and level debug is not logged`() { - fixture.options!!.setDiagnosticLevel(SentryLevel.INFO) + fixture.options.setDiagnosticLevel(SentryLevel.INFO) val sut = fixture.getSut() val expectedLevel = SentryLevel.DEBUG sut.log(expectedLevel, expectedMessage) @@ -70,7 +70,7 @@ class DiagnosticLoggerTest { @Test fun `when debug is true and option level is error, a call to log and level fatal is logged`() { - fixture.options!!.setDiagnosticLevel(SentryLevel.ERROR) + fixture.options.setDiagnosticLevel(SentryLevel.ERROR) val sut = fixture.getSut() val expectedLevel = SentryLevel.FATAL sut.log(expectedLevel, expectedMessage) @@ -79,7 +79,7 @@ class DiagnosticLoggerTest { @Test fun `when debug is false and option level is fatal, a call to log and level error is not logged`() { - fixture.options!!.isDebug = false + fixture.options.isDebug = false val sut = fixture.getSut() val expectedLevel = SentryLevel.FATAL sut.log(expectedLevel, expectedMessage) @@ -88,7 +88,7 @@ class DiagnosticLoggerTest { @Test fun `when debug is true option level is info, a call to log and level debug is not logged`() { - fixture.options!!.setDiagnosticLevel(SentryLevel.FATAL) + fixture.options.setDiagnosticLevel(SentryLevel.FATAL) val sut = fixture.getSut() val expectedLevel = SentryLevel.DEBUG sut.log(expectedLevel, expectedMessage) @@ -97,7 +97,7 @@ class DiagnosticLoggerTest { @Test fun `when debug is true option level is debug, a call to log with throwable and level info is logged`() { - fixture.options!!.setDiagnosticLevel(SentryLevel.DEBUG) + fixture.options.setDiagnosticLevel(SentryLevel.DEBUG) val sut = fixture.getSut() val expectedLevel = SentryLevel.INFO sut.log(expectedLevel, expectedMessage, expectedThrowable) @@ -106,8 +106,8 @@ class DiagnosticLoggerTest { @Test fun `when debug is false option level is debug, a call to log with throwable and level info is not logged`() { - fixture.options!!.isDebug = false - fixture.options!!.setDiagnosticLevel(SentryLevel.DEBUG) + fixture.options.isDebug = false + fixture.options.setDiagnosticLevel(SentryLevel.DEBUG) val sut = fixture.getSut() val expectedLevel = SentryLevel.INFO sut.log(expectedLevel, expectedMessage, expectedThrowable) @@ -116,7 +116,7 @@ class DiagnosticLoggerTest { @Test fun `when debug is true option level is error, a call to log with throwable and level fatal is logged`() { - fixture.options!!.setDiagnosticLevel(SentryLevel.ERROR) + fixture.options.setDiagnosticLevel(SentryLevel.ERROR) val sut = fixture.getSut() val expectedLevel = SentryLevel.FATAL sut.log(expectedLevel, expectedMessage, expectedThrowable) @@ -125,26 +125,26 @@ class DiagnosticLoggerTest { @Test fun `when debug is true option level is error, a call to log with throwable and level error is logged`() { - fixture.options!!.setDiagnosticLevel(SentryLevel.ERROR) + fixture.options.setDiagnosticLevel(SentryLevel.ERROR) val sut = fixture.getSut() - val expectedLevel = fixture.options!!.diagnosticLevel + val expectedLevel = fixture.options.diagnosticLevel sut.log(expectedLevel, expectedMessage, expectedThrowable) verify(fixture.logger)!!.log(expectedLevel, expectedMessage, expectedThrowable) } @Test fun `when debug is true option level is error, a call to log and level error is logged`() { - fixture.options!!.setDiagnosticLevel(SentryLevel.ERROR) + fixture.options.setDiagnosticLevel(SentryLevel.ERROR) val sut = fixture.getSut() - val expectedLevel = fixture.options!!.diagnosticLevel + val expectedLevel = fixture.options.diagnosticLevel sut.log(expectedLevel, expectedMessage) verify(fixture.logger)!!.log(expectedLevel, expectedMessage) } @Test fun `when debug is false option level is fatal, a call to log with throwable and level error is not logged`() { - fixture.options!!.isDebug = false - fixture.options!!.setDiagnosticLevel(SentryLevel.FATAL) + fixture.options.isDebug = false + fixture.options.setDiagnosticLevel(SentryLevel.FATAL) val sut = fixture.getSut() val expectedLevel = SentryLevel.ERROR sut.log(expectedLevel, expectedMessage, expectedThrowable) @@ -153,7 +153,7 @@ class DiagnosticLoggerTest { @Test fun `when debug is true option level is info, a call to log with throwable and level debug is not logged`() { - fixture.options!!.setDiagnosticLevel(SentryLevel.INFO) + fixture.options.setDiagnosticLevel(SentryLevel.INFO) val sut = fixture.getSut() val expectedLevel = SentryLevel.DEBUG sut.log(expectedLevel, expectedMessage, expectedThrowable) diff --git a/sentry-core/src/test/java/io/sentry/core/SendCachedEventFireAndForgetIntegrationTest.kt b/sentry-core/src/test/java/io/sentry/core/SendCachedEventFireAndForgetIntegrationTest.kt index 786910dfb..9c242ff75 100644 --- a/sentry-core/src/test/java/io/sentry/core/SendCachedEventFireAndForgetIntegrationTest.kt +++ b/sentry-core/src/test/java/io/sentry/core/SendCachedEventFireAndForgetIntegrationTest.kt @@ -37,19 +37,19 @@ class SendCachedEventFireAndForgetIntegrationTest { @Test fun `path is invalid if it is null`() { - val sut = fixture.getSut() + fixture.getSut() assertFalse(fixture.callback.hasValidPath(null, fixture.logger)) } @Test fun `path is invalid if it is empty`() { - val sut = fixture.getSut() + fixture.getSut() assertFalse(fixture.callback.hasValidPath("", fixture.logger)) } @Test fun `path is valid if not null or empty`() { - val sut = fixture.getSut() + fixture.getSut() assertFalse(fixture.callback.hasValidPath("cache", fixture.logger)) } diff --git a/sentry-core/src/test/java/io/sentry/core/SentryClientTest.kt b/sentry-core/src/test/java/io/sentry/core/SentryClientTest.kt index 967ad52ac..560ed7e02 100644 --- a/sentry-core/src/test/java/io/sentry/core/SentryClientTest.kt +++ b/sentry-core/src/test/java/io/sentry/core/SentryClientTest.kt @@ -403,19 +403,6 @@ class SentryClientTest { assertEquals(transportGate, sentryOptions.transportGate) } - @Test - fun `when transport gate is null, it should init an always on transport gate`() { - val sentryOptions: SentryOptions = SentryOptions().apply { - dsn = dsnString - } - - val connection = mock() - SentryClient(sentryOptions, connection) - - assertNotNull(sentryOptions.transportGate) - assertTrue(sentryOptions.transportGate!!.isConnected) - } - @Test fun `when scope has event processors, they should be applied`() { val event = SentryEvent()