🎨 Use equalTo instead of is
[Sone.git] / src / test / kotlin / net / pterodactylus / sone / utils / BucketsTest.kt
1 package net.pterodactylus.sone.utils
2
3 import freenet.support.api.Bucket
4 import net.pterodactylus.sone.test.mock
5 import org.junit.Test
6 import org.mockito.Mockito.verify
7 import kotlin.test.fail
8
9 /**
10  * Unit test for [freenet.support.api.Bucket]-related utilities.
11  */
12 class BucketsTest {
13
14         private val bucket = mock<Bucket>()
15
16         @Test
17         fun `bucket is freed after use without exception`() {
18                 bucket.use { }
19                 verify(bucket).free()
20         }
21
22         @Test
23         fun `bucket is freed after use with exceptions`() {
24                 try {
25                         bucket.use { throw Exception() }
26                         @Suppress("UNREACHABLE_CODE")
27                         fail()
28                 } catch (e: Exception) {
29                 } finally {
30                         verify(bucket).free()
31                 }
32         }
33
34 }