1
1
package io.sentry.android.gradle.tasks
2
2
3
+ import com.google.common.truth.Truth.assertThat
3
4
import io.sentry.android.gradle.sourcecontext.BundleSourcesTask
4
5
import io.sentry.android.gradle.sourcecontext.GenerateBundleIdTask.Companion.SENTRY_BUNDLE_ID_PROPERTY
5
6
import java.io.File
6
7
import java.util.Properties
7
8
import java.util.UUID
8
- import kotlin.test.assertEquals
9
- import kotlin.test.assertFalse
10
- import kotlin.test.assertNull
11
- import kotlin.test.assertTrue
12
9
import org.gradle.api.Project
13
10
import org.gradle.api.file.RegularFile
14
11
import org.gradle.api.provider.Provider
@@ -40,15 +37,15 @@ class BundleSourcesTaskTest {
40
37
41
38
val args = task.get().computeCommandLineArgs()
42
39
43
- assertTrue( " sentry-cli" in args )
44
- assertTrue( " debug-files" in args )
45
- assertTrue( " bundle-jvm" in args )
46
- assertTrue( sourceDir.absolutePath in args )
47
- assertTrue( " --output=${outDir.absolutePath} " in args )
40
+ assertThat(args).contains( " sentry-cli" )
41
+ assertThat(args).contains( " debug-files" )
42
+ assertThat(args).contains( " bundle-jvm" )
43
+ assertThat(args).contains( sourceDir.absolutePath)
44
+ assertThat(args).contains( " --output=${outDir.absolutePath} " )
48
45
49
- assertFalse( " --org" in args )
50
- assertFalse( " --project" in args )
51
- assertFalse( " --log-level=debug" in args )
46
+ assertThat(args).doesNotContain( " --org" )
47
+ assertThat(args).doesNotContain( " --project" )
48
+ assertThat(args).doesNotContain( " --log-level=debug" )
52
49
}
53
50
54
51
@Test
@@ -69,7 +66,7 @@ class BundleSourcesTaskTest {
69
66
70
67
val args = task.get().computeCommandLineArgs()
71
68
72
- assertTrue( " --log-level=debug" in args )
69
+ assertThat(args).contains( " --log-level=debug" )
73
70
}
74
71
75
72
@Test
@@ -91,10 +88,8 @@ class BundleSourcesTaskTest {
91
88
92
89
task.get().setSentryPropertiesEnv()
93
90
94
- assertEquals(
95
- propertiesFile.absolutePath,
96
- task.get().environment[" SENTRY_PROPERTIES" ].toString(),
97
- )
91
+ assertThat(task.get().environment[" SENTRY_PROPERTIES" ].toString())
92
+ .isEqualTo(propertiesFile.toString())
98
93
}
99
94
100
95
@Test
@@ -115,7 +110,7 @@ class BundleSourcesTaskTest {
115
110
116
111
task.get().setSentryAuthTokenEnv()
117
112
118
- assertEquals( " <token> " , task.get().environment[ " SENTRY_AUTH_TOKEN" ].toString() )
113
+ assertThat( task.get().environment).containsEntry( " SENTRY_AUTH_TOKEN" , " <token> " )
119
114
}
120
115
121
116
@Test
@@ -135,7 +130,7 @@ class BundleSourcesTaskTest {
135
130
136
131
task.get().setSentryPropertiesEnv()
137
132
138
- assertNull (task.get().environment[ " SENTRY_PROPERTIES" ] )
133
+ assertThat (task.get().environment).doesNotContainKey( " SENTRY_PROPERTIES" )
139
134
}
140
135
141
136
@Test
@@ -156,8 +151,8 @@ class BundleSourcesTaskTest {
156
151
157
152
val args = task.get().computeCommandLineArgs()
158
153
159
- assertTrue( " --org" in args )
160
- assertTrue( " dummy-org" in args )
154
+ assertThat(args).contains( " --org" )
155
+ assertThat(args).contains( " dummy-org" )
161
156
}
162
157
163
158
@Test
@@ -178,24 +173,24 @@ class BundleSourcesTaskTest {
178
173
179
174
val args = task.get().computeCommandLineArgs()
180
175
181
- assertTrue( " --project" in args )
182
- assertTrue( " dummy-proj" in args )
176
+ assertThat(args).contains( " --project" )
177
+ assertThat(args).contains( " dummy-proj" )
183
178
}
184
179
185
180
@Test
186
181
fun `readBundleIdFromFile works correctly` () {
187
182
val expected = " 8c776014-bb25-11eb-8529-0242ac130003"
188
183
val input = tempDir.newFile().apply { writeText(" $SENTRY_BUNDLE_ID_PROPERTY =$expected " ) }
189
184
val actual = BundleSourcesTask .readBundleIdFromFile(input)
190
- assertEquals(expected, actual)
185
+ assertThat( actual).isEqualTo(expected )
191
186
}
192
187
193
188
@Test
194
189
fun `readBundleIdFromFile works correctly with whitespaces` () {
195
190
val expected = " 8c776014-bb25-11eb-8529-0242ac130003"
196
191
val input = tempDir.newFile().apply { writeText(" $SENTRY_BUNDLE_ID_PROPERTY =$expected \n " ) }
197
192
val actual = BundleSourcesTask .readBundleIdFromFile(input)
198
- assertEquals(expected, actual)
193
+ assertThat( actual).isEqualTo(expected )
199
194
}
200
195
201
196
@Test
@@ -238,8 +233,8 @@ class BundleSourcesTaskTest {
238
233
239
234
val args = task.get().computeCommandLineArgs()
240
235
241
- assertTrue( " --url" in args )
242
- assertTrue( " https://some-host.sentry.io" in args )
236
+ assertThat(args).contains( " --url" )
237
+ assertThat(args).contains( " https://some-host.sentry.io" )
243
238
}
244
239
245
240
private fun createProject (): Project {
0 commit comments