mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-11-15 17:02:06 +01:00
Atomize CertificationSetTest test cases and use backtick notation for test names
This commit is contained in:
parent
2dcc1ae56e
commit
3069e92cb2
1 changed files with 41 additions and 11 deletions
|
@ -23,15 +23,15 @@ class CertificationSetTest {
|
||||||
private val charlieSignsBob = Certification(charlie, null, bob, Date())
|
private val charlieSignsBob = Certification(charlie, null, bob, Date())
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun emptyCertificationSet() {
|
fun `verify that properties of an empty CertificationSet are also empty`() {
|
||||||
val empty = CertificationSet.empty(alice, bob)
|
val empty = CertificationSet.empty(alice, bob)
|
||||||
assertTrue { empty.certifications.isEmpty() }
|
assert(empty.certifications.isEmpty())
|
||||||
assertEquals(alice, empty.issuer)
|
assertEquals(alice, empty.issuer)
|
||||||
assertEquals(bob, empty.target)
|
assertEquals(bob, empty.target)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun addCertification() {
|
fun `verify that add()ing Certification objects works if issuer and target match that of the CertificationSet`() {
|
||||||
val set = CertificationSet.empty(alice, bob)
|
val set = CertificationSet.empty(alice, bob)
|
||||||
|
|
||||||
set.add(aliceSignsBob)
|
set.add(aliceSignsBob)
|
||||||
|
@ -44,33 +44,63 @@ class CertificationSetTest {
|
||||||
assertTrue {
|
assertTrue {
|
||||||
set.certifications["Bob <bob@example.org>"]!!.contains(aliceSignsBobUserId)
|
set.certifications["Bob <bob@example.org>"]!!.contains(aliceSignsBobUserId)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `verify that add()ing another Certification object fails if the issuer mismatches`() {
|
||||||
|
val set = CertificationSet.empty(alice, bob)
|
||||||
assertThrows<IllegalArgumentException> { set.add(charlieSignsBob) }
|
assertThrows<IllegalArgumentException> { set.add(charlieSignsBob) }
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `verify that add()ing another Certification object fails if the target mismatches`() {
|
||||||
|
val set = CertificationSet.empty(alice, bob)
|
||||||
assertThrows<IllegalArgumentException> { set.add(aliceSignsCharlie) }
|
assertThrows<IllegalArgumentException> { set.add(aliceSignsCharlie) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun mergeCertificationSets() {
|
fun `verify that merge()ing another CertificationSet works if issuer and target match that of the CertificationSet`() {
|
||||||
val set = CertificationSet.fromCertification(aliceSignsBob)
|
val set = CertificationSet.fromCertification(aliceSignsBob)
|
||||||
val others = CertificationSet.fromCertification(aliceSignsBobUserId)
|
val others = CertificationSet.fromCertification(aliceSignsBobUserId)
|
||||||
val mismatch = CertificationSet.fromCertification(charlieSignsBob)
|
|
||||||
|
|
||||||
set.merge(others)
|
set.merge(others)
|
||||||
assertEquals(2, set.certifications.size)
|
assertEquals(2, set.certifications.size)
|
||||||
assertTrue { set.certifications[null]!!.contains(aliceSignsBob) }
|
assertTrue { set.certifications[null]!!.contains(aliceSignsBob) }
|
||||||
assertTrue { set.certifications["Bob <bob@example.org>"]!!.contains(aliceSignsBobUserId) }
|
assertTrue { set.certifications["Bob <bob@example.org>"]!!.contains(aliceSignsBobUserId) }
|
||||||
|
|
||||||
assertThrows<IllegalArgumentException> { set.merge(mismatch) }
|
|
||||||
|
|
||||||
set.merge(set)
|
|
||||||
assertEquals(2, set.certifications.size)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testToString() {
|
fun `verify that merge()ing another CertificationSet with mismatched issuer fails`() {
|
||||||
|
val set = CertificationSet.fromCertification(aliceSignsBob)
|
||||||
|
val issuerMismatch = CertificationSet.fromCertification(charlieSignsBob)
|
||||||
|
|
||||||
|
assertThrows<IllegalArgumentException> { set.merge(issuerMismatch) }
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `verify that merge()ing another CertificationSet with mismatched target fails`() {
|
||||||
|
val set = CertificationSet.fromCertification(aliceSignsBob)
|
||||||
|
val targetMismatch = CertificationSet.fromCertification(aliceSignsCharlie)
|
||||||
|
|
||||||
|
assertThrows<IllegalArgumentException> { set.merge(targetMismatch) }
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `verify that merge()ing a CertificationSet with itself is idempotent`() {
|
||||||
|
val set = CertificationSet.fromCertification(aliceSignsBob)
|
||||||
|
assertEquals(1, set.certifications.size)
|
||||||
|
set.merge(set)
|
||||||
|
assertEquals(1, set.certifications.size)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `verify that toString() of an empty CertificationSet is the empty string`() {
|
||||||
val empty = CertificationSet.empty(alice, bob)
|
val empty = CertificationSet.empty(alice, bob)
|
||||||
assertEquals("", empty.toString())
|
assertEquals("", empty.toString())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `verify that toString() of a CertificationSet with two Certifications matches our expectations`() {
|
||||||
val twoCerts = CertificationSet.fromCertification(aliceSignsBob)
|
val twoCerts = CertificationSet.fromCertification(aliceSignsBob)
|
||||||
twoCerts.add(aliceSignsBobUserId)
|
twoCerts.add(aliceSignsBobUserId)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue