Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ public boolean invalidate() {
}
try {
final boolean result = delegate.invalidate();
span.setData(SpanDataConvention.CACHE_WRITE, true);
span.setData(SpanDataConvention.CACHE_WRITE, result);
span.setStatus(SpanStatus.OK);
return result;
} catch (Throwable e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import kotlin.test.BeforeTest
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
import kotlin.test.assertFalse
import kotlin.test.assertNull
import kotlin.test.assertTrue
import org.mockito.kotlin.any
Expand Down Expand Up @@ -450,6 +451,21 @@ class SentryCacheWrapperTest {
assertEquals("invalidate", tx.spans.first().getData(SpanDataConvention.CACHE_OPERATION))
}

@Test
fun `invalidate sets cache write false when cache had no mappings`() {
val tx = createTransaction()
val wrapper = SentryCacheWrapper(delegate, scopes)
whenever(delegate.invalidate()).thenReturn(false)

val result = wrapper.invalidate()

assertFalse(result)
assertEquals(1, tx.spans.size)
assertEquals("cache.invalidate", tx.spans.first().operation)
assertEquals(false, tx.spans.first().getData(SpanDataConvention.CACHE_WRITE))
assertEquals("invalidate", tx.spans.first().getData(SpanDataConvention.CACHE_OPERATION))
}

// -- no span when no active transaction --

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ public boolean invalidate() {
}
try {
final boolean result = delegate.invalidate();
span.setData(SpanDataConvention.CACHE_WRITE, true);
span.setData(SpanDataConvention.CACHE_WRITE, result);
span.setStatus(SpanStatus.OK);
return result;
} catch (Throwable e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import kotlin.test.BeforeTest
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
import kotlin.test.assertFalse
import kotlin.test.assertNull
import kotlin.test.assertTrue
import org.mockito.kotlin.any
Expand Down Expand Up @@ -450,6 +451,21 @@ class SentryCacheWrapperTest {
assertEquals("invalidate", tx.spans.first().getData(SpanDataConvention.CACHE_OPERATION))
}

@Test
fun `invalidate sets cache write false when cache had no mappings`() {
val tx = createTransaction()
val wrapper = SentryCacheWrapper(delegate, scopes)
whenever(delegate.invalidate()).thenReturn(false)

val result = wrapper.invalidate()

assertFalse(result)
assertEquals(1, tx.spans.size)
assertEquals("cache.invalidate", tx.spans.first().operation)
assertEquals(false, tx.spans.first().getData(SpanDataConvention.CACHE_WRITE))
assertEquals("invalidate", tx.spans.first().getData(SpanDataConvention.CACHE_OPERATION))
}

// -- no span when no active transaction --

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public boolean invalidate() {
}
try {
final boolean result = delegate.invalidate();
span.setData(SpanDataConvention.CACHE_WRITE, true);
span.setData(SpanDataConvention.CACHE_WRITE, result);
span.setStatus(SpanStatus.OK);
return result;
} catch (Throwable e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import kotlin.test.BeforeTest
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
import kotlin.test.assertFalse
import kotlin.test.assertNull
import kotlin.test.assertTrue
import org.mockito.kotlin.any
Expand Down Expand Up @@ -274,6 +275,21 @@ class SentryCacheWrapperTest {
assertEquals("invalidate", tx.spans.first().getData(SpanDataConvention.CACHE_OPERATION))
}

@Test
fun `invalidate sets cache write false when cache had no mappings`() {
val tx = createTransaction()
val wrapper = SentryCacheWrapper(delegate, scopes)
whenever(delegate.invalidate()).thenReturn(false)

val result = wrapper.invalidate()

assertFalse(result)
assertEquals(1, tx.spans.size)
assertEquals("cache.invalidate", tx.spans.first().operation)
assertEquals(false, tx.spans.first().getData(SpanDataConvention.CACHE_WRITE))
assertEquals("invalidate", tx.spans.first().getData(SpanDataConvention.CACHE_OPERATION))
}

// -- no span when no active transaction --

@Test
Expand Down
Loading