From dc028e2f2222cb86409461534098a281aaad2b46 Mon Sep 17 00:00:00 2001
From: Sebastian <sebastian@mobanisto.de>
Date: Mon, 20 Dec 2021 16:46:04 +0000
Subject: [PATCH] Let CI run tests; add a test for the sake of having one

---
 .gitlab-ci.yml                                |  5 ++-
 .../briar/desktop/contact/ContactItemTest.kt  | 36 +++++++++++++++++++
 2 files changed, 40 insertions(+), 1 deletion(-)
 create mode 100644 src/test/kotlin/org/briarproject/briar/desktop/contact/ContactItemTest.kt

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index d5a92ee65a..05324b1626 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 0000000000..7f1ac69103
--- /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)
+    }
+}
-- 
GitLab