fix: test build fail duo invalid skip & take values;

This commit is contained in:
Hamed Masafi 2020-08-09 19:58:16 +04:30
parent e265b3ad02
commit 38e43dc61a
5 changed files with 20 additions and 9 deletions

View File

@ -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

View File

@ -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)
{
}

View File

@ -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()

View File

@ -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>();
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<Post>();
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);
}

View File

@ -46,7 +46,7 @@ void BenchmarkTest::insert1kPost()
for (int i = 0; i < 100; ++i) {
auto newPost = Nut::create<Post>();
newPost->setTitle("post title");
newPost->setTitle(QStringLiteral("post title"));
newPost->setSaveDate(QDateTime::currentDateTime());
db.posts()->append(newPost);