Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Threema/Threema/   (Threema ©)  Datei vom 26.9.2026 mit Größe 1000 B image not shown  

Quelle  EventEnricherTests.swift   Sprache: JAVA

 

import Sentry
import Testing
@testable import Threema

@MainActor
struct EventEnricherTests {

    @Test("Derives an anonymized user from the app device hash")
    func derivesAnonymizedUserFromAppDeviceHash() {
        var savedAppDevice: String?
        let enricher = EventEnricher(saveAppDevice: { savedAppDevice = $0 })

        let event = Sentry.Event()
        event.context = ["app": ["device_app_hash": "abc123"]]

        enricher.enrich(event)

        #expect(savedAppDevice == "abc123")
        // swiftformat:disable:next acronyms
        #expect(event.user?.userId == "abc123")
    }

    @Test("Leaves the event alone when it carries no app device hash")
    func withoutAppDeviceHash() {
        var savedAppDevice: String?
        let enricher = EventEnricher(saveAppDevice: { savedAppDevice = $0 })

        let event = Sentry.Event()
        event.context = ["app": [:]]

        enricher.enrich(event)

        #expect(savedAppDevice == nil)
        #expect(event.user == nil)
    }
}

Messung
CHZG
8210010094

¤ Dauer der Verarbeitung: 0.12 Sekunden  (vorverarbeitet am  2026-11-24) ¤

*© Formatika GbR, Deutschland