Skip to content

Commit

Permalink
fix: test build fail duo invalid skip & take values;
Browse files Browse the repository at this point in the history
  • Loading branch information
HamedMasafi committed Aug 9, 2020
1 parent e265b3a commit 38e43dc
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/qt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/nut/abstractquery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{

}
Expand Down
3 changes: 2 additions & 1 deletion tests/auto/common/consts.h
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
20 changes: 15 additions & 5 deletions tests/auto/tst_basic/tst_basic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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()
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/auto/tst_benckmark/tst_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 38e43dc

Please sign in to comment.