Skip to content

Commit 4a52a0d

Browse files
committed
add tests for path creation
1 parent 40bb0a2 commit 4a52a0d

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

sentry-async-profiler/src/test/java/io/sentry/asyncprofiler/init/AsyncProfilerInitUtilTest.kt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import io.sentry.asyncprofiler.profiling.JavaContinuousProfiler
99
import io.sentry.asyncprofiler.provider.AsyncProfilerProfileConverterProvider
1010
import io.sentry.util.InitUtil
1111
import kotlin.test.Test
12+
import kotlin.test.assertNotNull
1213
import kotlin.test.assertSame
1314
import org.mockito.kotlin.mock
1415

@@ -70,4 +71,26 @@ class AsyncProfilerInitUtilTest {
7071
assertSame(converter, options.profilerConverter)
7172
assert(converter is AsyncProfilerProfileConverterProvider.AsyncProfilerProfileConverter)
7273
}
74+
75+
@Test
76+
fun `initialize profiler uses existing profilingTracesDirPath when set`() {
77+
val customPath = "/custom/path/to/traces"
78+
val options =
79+
SentryOptions().also {
80+
it.setProfileSessionSampleRate(1.0)
81+
it.profilingTracesDirPath = customPath
82+
}
83+
val profiler = InitUtil.initializeProfiler(options)
84+
assert(profiler is JavaContinuousProfiler)
85+
assertSame(customPath, options.profilingTracesDirPath)
86+
}
87+
88+
@Test
89+
fun `initialize profiler creates and sets profilingTracesDirPath when null`() {
90+
val options = SentryOptions().also { it.setProfileSessionSampleRate(1.0) }
91+
val profiler = InitUtil.initializeProfiler(options)
92+
assert(profiler is JavaContinuousProfiler)
93+
assertNotNull(options.profilingTracesDirPath)
94+
assert(options.profilingTracesDirPath!!.contains("sentry_profiling_traces"))
95+
}
7396
}

0 commit comments

Comments
 (0)