File indexing completed on 2024-05-05 05:29:37

0001 // SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0002 // SPDX-FileCopyrightText: 2023 Harald Sitter <sitter@kde.org>
0003 
0004 #include <QTest>
0005 
0006 #include <sentryenvelope.h>
0007 
0008 using namespace Qt::StringLiterals;
0009 
0010 class SentryEnvelopeTest : public QObject
0011 {
0012     Q_OBJECT
0013 private Q_SLOTS:
0014     void testConstruction()
0015     {
0016         const auto payload = "{\"event_id\":\"9ec79c33ec9942ab8353589fcb2e04dc\",\"message\":\"hello world\",\"level\":\"error\"}\n"_qba;
0017         SentryEnvelope envelope;
0018         // Fixate for test
0019         envelope.m_headers["event_id"] = "9ec79c33ec9942ab8353589fcb2e04dc";
0020         envelope.setDSN(QUrl("https://foo.bar"_L1));
0021         envelope.addItem(SentryEvent(payload));
0022         envelope.addItem(SentryUserFeedback("{\"email\":\"john@me.com\",\"name\":\"John Me\",\"comments\":\"It broke.\"}\n"_qba));
0023 
0024         QFile f(QFINDTESTDATA("data/sentryenvelope"));
0025         QVERIFY(f.open(QFile::ReadOnly));
0026         QCOMPARE(envelope.toEnvelope(), f.readAll());
0027     }
0028 };
0029 
0030 QTEST_GUILESS_MAIN(SentryEnvelopeTest)
0031 
0032 #include "sentryenvelopetest.moc"