From 38e43dc61a9fb67512c502861aa09c72e2b28135 Mon Sep 17 00:00:00 2001 From: Hamed Masafi Date: Sun, 9 Aug 2020 19:58:16 +0430 Subject: [PATCH] fix: test build fail duo invalid skip & take values; --- .github/workflows/qt.yml | 2 +- src/nut/abstractquery.cpp | 2 +- tests/auto/common/consts.h | 3 ++- tests/auto/tst_basic/tst_basic.cpp | 20 +++++++++++++++----- tests/auto/tst_benckmark/tst_benchmark.cpp | 2 +- 5 files changed, 20 insertions(+), 9 deletions(-) diff --git a/.github/workflows/qt.yml b/.github/workflows/qt.yml index 8c7dc06..fc0c9d9 100644 --- a/.github/workflows/qt.yml +++ b/.github/workflows/qt.yml @@ -65,7 +65,7 @@ jobs: ${{steps.qt.outputs.make}} ${{steps.qt.outputs.make}} INSTALL_ROOT="${{steps.qt.outputs.installdir}}" install - name: make tests - if: steps.qt.outputs.tests == 'true' && !contains(matrix.platform, 'mingw') + if: steps.qt.outputs.tests == 'true' run: | ${{steps.qt.outputs.make}} all ${{steps.qt.outputs.make}} ${{steps.qt.outputs.testflags}} run-tests diff --git a/src/nut/abstractquery.cpp b/src/nut/abstractquery.cpp index f2dd832..2ea87ed 100644 --- a/src/nut/abstractquery.cpp +++ b/src/nut/abstractquery.cpp @@ -30,7 +30,7 @@ AbstractQuery::AbstractQuery(QObject *parent) : QObject(parent) } Nut::AbstractQueryPrivate::AbstractQueryPrivate(Nut::AbstractQuery *parent) : - q_ptr(parent) + q_ptr(parent), skip(0), take(0) { } diff --git a/tests/auto/common/consts.h b/tests/auto/common/consts.h index 8785e02..b861467 100644 --- a/tests/auto/common/consts.h +++ b/tests/auto/common/consts.h @@ -14,7 +14,8 @@ #define DRIVER QStringLiteral("QSQLITE") -#define DATABASE QStringLiteral("nut_test_%1_db").arg(metaObject()->className()).toLower() +#define DATABASE QStringLiteral("nut_test_%1_db") \ + .arg(QString::fromUtf8(metaObject()->className())).toLower() #define HOST QString() #define USERNAME QString() #define PASSWORD QString() diff --git a/tests/auto/tst_basic/tst_basic.cpp b/tests/auto/tst_basic/tst_basic.cpp index 24e86fc..5fbdd2b 100644 --- a/tests/auto/tst_basic/tst_basic.cpp +++ b/tests/auto/tst_basic/tst_basic.cpp @@ -98,7 +98,7 @@ void BasicTest::createPost2() { //create post on the fly QVariant postIdVar = db.posts()->query()->insert( - (Post::titleField() = "This is a sample") + (Post::titleField() = QStringLiteral("This is a sample")) & (Post::isPublicField() = true)); QVERIFY(postIdVar.type() == QVariant::LongLong @@ -108,7 +108,7 @@ void BasicTest::createPost2() for(int i = 0 ; i < 3; i++){ auto comment = Nut::create(); - comment->setMessage("comment #" + QString::number(i + 2)); + comment->setMessage(QStringLiteral("comment #") + QString::number(i + 2)); comment->setSaveDate(QDateTime::currentDateTime()); comment->setAuthor(user); //join child to master by id @@ -124,9 +124,17 @@ void BasicTest::updatePostOnTheFly() { auto c = db.posts()->query() ->where(Post::idField() == postId) - ->update(Post::titleField() = "New title"); + ->update(Post::titleField() = QStringLiteral("New title")); QCOMPARE(c, 1); + + auto titles = db.posts() + ->query() + ->where(Post::idField() == postId) + ->select(Post::titleField()); + + QCOMPARE(titles.count(), 1); + QCOMPARE(titles.at(0), QStringLiteral("New title")); } void BasicTest::selectPublicts() @@ -224,7 +232,7 @@ void BasicTest::testDate() d.setTime(t); auto newPost = Nut::create(); - newPost->setTitle("post title"); + newPost->setTitle(QStringLiteral("post title")); newPost->setSaveDate(d); db.posts()->append(newPost); @@ -241,7 +249,9 @@ void BasicTest::testDate() void BasicTest::testLimitedQuery() { - auto comments = db.comments()->query()->toList(2); + auto q = db.comments()->query(); + auto comments = q->toList(2); + qDebug() << q->sqlCommand(); QCOMPARE(comments.length(), 2); } diff --git a/tests/auto/tst_benckmark/tst_benchmark.cpp b/tests/auto/tst_benckmark/tst_benchmark.cpp index 39a5376..0c6119d 100644 --- a/tests/auto/tst_benckmark/tst_benchmark.cpp +++ b/tests/auto/tst_benckmark/tst_benchmark.cpp @@ -46,7 +46,7 @@ void BenchmarkTest::insert1kPost() for (int i = 0; i < 100; ++i) { auto newPost = Nut::create(); - newPost->setTitle("post title"); + newPost->setTitle(QStringLiteral("post title")); newPost->setSaveDate(QDateTime::currentDateTime()); db.posts()->append(newPost);