############################################################################## ################## import the result of a custom query ###################### ##############################################################################
| 288 | // ################## import the result of a custom query ###################### |
| 289 | // ############################################################################## |
| 290 | void ImportSqlDatabaseTest::testQuery() { |
| 291 | // prepare the target spreadsheet |
| 292 | Spreadsheet spreadsheet(QStringLiteral("test"), false); |
| 293 | |
| 294 | // import the resultset of a custom query |
| 295 | ImportSQLDatabaseWidget w; |
| 296 | w.loadSettings(); |
| 297 | w.setCustomQuery(true); |
| 298 | w.setQuery(QLatin1String("select title from albums where title like '%best%';")); |
| 299 | w.refreshPreview(); |
| 300 | w.read(&spreadsheet, AbstractFileFilter::ImportMode::Replace); |
| 301 | |
| 302 | // check the spreadsheet size and columns names and modes |
| 303 | QCOMPARE(spreadsheet.rowCount(), 15); |
| 304 | QCOMPARE(spreadsheet.columnCount(), 1); |
| 305 | |
| 306 | QCOMPARE(spreadsheet.column(0)->name(), QLatin1String("Title")); |
| 307 | QCOMPARE(spreadsheet.column(0)->columnMode(), AbstractColumn::ColumnMode::Text); |
| 308 | |
| 309 | // first row in the spreadsheet |
| 310 | QCOMPARE(spreadsheet.column(0)->textAt(0), QLatin1String("The Best Of Billy Cobham")); |
| 311 | |
| 312 | // last row in the spreadsheet |
| 313 | QCOMPARE(spreadsheet.column(0)->textAt(14), QLatin1String("The Best of Beethoven")); |
| 314 | } |
| 315 | |
| 316 | // ############################################################################## |
| 317 | // ################################# export #################################### |
nothing calls this directly
no test coverage detected