Added recordCount and fieldCount Test
Needs RevisionPublic

Authored by dwivedi on Jun 7 2017, 6:24 AM.

Diff Detail

Repository
R15 KDb
Branch
master
Lint
No Linters Available
Unit
No Unit Test Coverage
dwivedi created this revision.Jun 7 2017, 6:24 AM
Restricted Application added a project: KDb. ยท View Herald TranscriptJun 7 2017, 6:24 AM
staniek requested changes to this revision.Jun 7 2017, 2:57 PM
staniek added inline comments.
autotests/KDbTest.cpp
1208

Idea, test more cases:

  • pass invalid table name to KDbTableOrQuerySchema so there is no table found; -1 result expected
  • create an empty KDbQuerySchema() and pass to KDbTableOrQuerySchema; -1 result expected because it has no connection assigned
  • create an KDbQuerySchema(kdb_t) query; expected result == 4 because it's a "SELECT * ..." query
  • test 3 other overloads of KDb::recordCount()
    • int recordCount(KDbConnection* conn, const KDbEscapedString& sql) (with valid and invalid SQL)
    • int recordCount(const KDbTableSchema& tableSchema);
    • int recordCount(KDbQuerySchema* querySchema, const QList<QVariant>& params = QList<QVariant>());
  • test parameter queries (i.e. calls with const QList<QVariant>& params set)
  • test all the overloads with nullptr connection or table/query arguments, -1 expected (actually there will be some crashes, will fix this :) )
1211

Let's use QCOMPARE() for any comparisons of values other than bool.

Then "Number of records in default persons table is 4." is implied.

1225

Please create on stack, memory leak otherwise.

So:

KDbTableOrQuerySchema tableOrQuery(utils.connection.data(), "persons");
1227

not needed, always present

1231

Not needed

This revision now requires changes to proceed.Jun 7 2017, 2:57 PM
staniek added inline comments.Jun 10 2017, 8:25 PM
autotests/KDbTest.cpp
1208

By the way, it's not a problem to implement the above TODO in separate commit. Feel free to just perform the other improvements I requested below.