diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d5a92ee65acf303530fdb567021426988722a6de..05324b1626e262f8bbe605d88cdd60c6e4460c53 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,13 +12,16 @@ workflow: - if: '$CI_COMMIT_BRANCH' - if: '$CI_COMMIT_TAG' +variables: + GIT_SUBMODULE_STRATEGY: recursive + test: stage: test before_script: - set -e - export GRADLE_USER_HOME=$PWD/.gradle script: - - ./gradlew --no-daemon ktlintCheck + - ./gradlew --no-daemon :check after_script: # these file change every time and should not be cached - rm -f $GRADLE_USER_HOME/caches/modules-2/modules-2.lock diff --git a/src/test/kotlin/org/briarproject/briar/desktop/contact/ContactItemTest.kt b/src/test/kotlin/org/briarproject/briar/desktop/contact/ContactItemTest.kt new file mode 100644 index 0000000000000000000000000000000000000000..7f1ac6910312b573acc30766b36db15804053dc9 --- /dev/null +++ b/src/test/kotlin/org/briarproject/briar/desktop/contact/ContactItemTest.kt @@ -0,0 +1,36 @@ +package org.briarproject.briar.desktop.contact + +import org.briarproject.bramble.api.UniqueId +import org.briarproject.bramble.api.contact.ContactId +import org.briarproject.bramble.api.identity.AuthorId +import kotlin.random.Random +import kotlin.test.Test +import kotlin.test.assertEquals + +class ContactItemTest { + + @Test + fun test() { + val random = Random(1) + val item = ContactItem( + idWrapper = RealContactIdWrapper(ContactId(random.nextInt())), + authorId = AuthorId(random.nextBytes(UniqueId.LENGTH)), + name = "Alice", + alias = null, + isConnected = false, + isEmpty = false, + unread = 10, + timestamp = random.nextLong() + ) + assertEquals("Alice", item.displayName) + + val updated = item.updateAlias("liz") + assertEquals("liz (Alice)", updated.displayName) + + // old item did not get updated + assertEquals("Alice", item.displayName) + + val reset = updated.updateAlias(null) + assertEquals("Alice", reset.displayName) + } +}