/// Puts a test case into the database. /// /// \pre The test case has not been put yet. /// \post The test case is stored into the database with a new identifier. /// /// \param test_program The program containing the test case to be stored. /// \param test_case_name The name of the test case to put. /// \param test_program_id The test program this test case belongs to. /// /// \return The identifier of the inserted test case. /// /// \throw error If there is any problem when talking to the database. int64_t store::write_transaction::put_test_case(const model::test_program& test_program, const std::string& test_case_name, const int64_t test_program_id) { const model::test_case& test_case = test_program.find(test_case_name); try { const int64_t metadata_id = put_metadata( _pimpl->_db, test_case.get_raw_metadata()); sqlite::statement stmt = _pimpl->_db.create_statement( "INSERT INTO test_cases (test_program_id, name, metadata_id) " "VALUES (:test_program_id, :name, :metadata_id)"); stmt.bind(":test_program_id", test_program_id); stmt.bind(":name", test_case.name()); stmt.bind(":metadata_id", metadata_id); stmt.step_without_results(); return _pimpl->_db.last_insert_rowid(); } catch (const sqlite::error& e) { throw error(e.what()); } }