Warning, /office/kexi/src/tests/altertable/README is written in an unsupported language. File is not indexed.

0001 ===================================================
0002  README for the "altertable" test
0003  Copyright (C) 2006 Jarosław Staniek <staniek@kde.org>
0004 ===================================================
0005 
0006 
0007 Invoking
0008 --------
0009 "altertable" test requires <db_name>, <driver_name> and <alterscript> arguments
0010 
0011 The purpose of .altertable files
0012 --------------------------------
0013 .altertable files are provoded to test a given use case of table altering. 
0014 It contains a set of commands mapped to a sequence of ALTER TABLE and other 
0015 SQL statements. The commands are mapped to AlterTableHandler::***Action objects, 
0016 what is equat to actions performed by the user during the table designing.
0017 
0018 Second purpose of the test is testing the Table Designer's GUI itself. 
0019 Whenever there is a bug in a the GUI, e.g. in the property editor,
0020 the resulting schema can differ from expected, or there can be even a crash.
0021 The suite already helped to find a few bugs in the GUI code.
0022 
0023 
0024 How the test is performed, .alterscript file contents
0025 -----------------------------------------------------
0026 
0027 The file can be consisted of many sections described below. The test can be built by:
0028 a. requesting a table design to be opened in the Table designer,
0029 b. specifying commands affecting the design, 
0030 c. then checking the actions sequence genrated by the "alter table machinery" 
0031    (it's a method that allocates AlterTableHandler::***Action objects and add them 
0032    using AlterTableHandler::addAction() to the alte table machinery. 
0033    The result is the same as user's actions);
0034 d. then saving the design, 
0035 e. and finally checking the table data with the expected table contents.
0036 Every comparison is performed line by line: obtained result is compared with expected one.
0037 
0038 2. Expected result of altering the table. 
0039    It's a full human-redable dump of table schema and its contents.
0040 
0041 Each section has a strictly defined format, so the test suite can combine commands into more complex sets.
0042 
0043 
0044 Available commands of the test suite
0045 ------------------------------------
0046 
0047 1. Top-level commands
0048 
0049 * openDatabase <filename>
0050   Opens kexi database for tests. In fact the file is copied to a temporary file (with .tmp suffix) 
0051   and we're dealing with the copy, so the original could not be broken. Thus, tests can be reproduced.
0052 #TODO: support server databases
0053   Example use: openDatabase 1.kexi
0054 
0055 * designTable <tablename> \n <block> \n endDesign
0056   Opens table in design mode. <block> contains one or more schema altering 
0057   commands described in 2.
0058 
0059 2. Commands for altering table fields (during the design mode, within "designTable" command):
0060 
0061 * insertField <rownumber(int)> <fieldname(string)>
0062   Inserts a new table field with default properties (text type) and 'fieldname' name.
0063   Note that the inserted field can *replace* an existing field. To avoid this, use 
0064   insertEmptyRow command before insertField to add an empty row.
0065   Example use: insertField 2 abc
0066 
0067 * insertEmptyRow <rownumber(int)>
0068   Inserts empty row before 'rownumber'. Rows below are moved down.
0069   Example use: insertEmptyRow 2
0070 
0071 * removeField <rownumber(int)>
0072   Removes a table field at a specified row.
0073   Example use: removeField 1
0074 
0075 * changeFieldProperty <rownumber(int)> <propertyname(string)> <valuetype(string)> <value(string)>
0076   Changes property of table field at a specified row.
0077   'valuetype' can be int, string, bool, double/float, bool/boolean, data, dateTime, time, 
0078   bytearray, longlong. 
0079   <value(string)> should be a string representation of the value. Special cases are:
0080   byteArray: hexadecimal string like 'fd1a5c', dateTime: yyyy-mm-ddThh:mm:ss string 
0081   like '2005-11-05T12:34:56'.
0082   Null values should be specified as <null> string. Empty string values should be specified as "".
0083   'type' property means a field datatype, where value can be any of the names 
0084   in KexiDB::Field::Type enum, written as string, e.g. "integer","text", "date", etc. 
0085   Example use: changeFieldProperty 1 type string date
0086 
0087 * i++
0088   Increases "i" variable by 1. This integer variable is initialized to 1 before test is executed.
0089   Can be used as an argument for <rownumber(int)> for above field-related commands.
0090  
0091 * i=<number(int)>
0092   Sets "i" variable to <number(int)>.
0093   Example use: shows that using the variable instead of constants allows to insert 
0094   a command without a need for managing subsequent arguments.
0095         i=3
0096         removeField i
0097         insertField i textField
0098         changeFieldProperty i type string text
0099         i++ #i is now 4
0100         insertField i longTextField
0101         changeFieldProperty i type string longText
0102 
0103 3. Commands related to altered (not saved) table schema:
0104 
0105 * showSchema [clipboard]
0106   Shows schema dump as returned by KexiTableDesignerInterface::debugStringForCurrentTableSchema().
0107   Useful for creating "checkSchema" checks: Just paste the output to the test file.
0108   You can use "clipboard" word to copy prepare the schema dump to clipboard.
0109 
0110 * checkSchema \n <block> \n endSchema
0111   Checks validity of the not yet saved schema altered in the Table Designer using the
0112   actions listed in p. 1. The <block> should end with "endSchema" line.
0113   Between these lines there should be pasted a <block> - exact textual schema dump as returned 
0114   by KexiTableDesignerInterface::debugStringForCurrentTableSchema(). 
0115   The check compares lines returned from the Designer with the lines you provided, line by line.
0116   You can use "showSchema" command to display the expected schema to the stderr and copy the text.
0117   Every line contains up to three main sections <fieldname> <type> [<constraints>].
0118   The lines can be indented - trailing and leading whitespaces are ignored in comparison.
0119   Example use:
0120  checkSchema
0121   textfield Text(200)
0122   owner  UNSIGNED Integer
0123   booleanfield Boolean NOTNULL
0124  endSchema
0125 
0126 4. Commands related to simplified list of Alter Table actions (simulated, before real saving):
0127 
0128 * showActions [clipboard]
0129   Shows the list of simplified Alter Table actions that are result of commands related to table fields, 
0130   mentioned in 1.
0131   You can use "clipboard" word to copy prepare the expected actions dump to clipboard.
0132 
0133 * checkActions \n <block> \n endActions
0134   Checks validity of the list of simplified Alter Table actions. 
0135   The <block> should end with "endActions" line.
0136   The check compares lines returned from the Designer with the lines you provided as <block>, line by line.
0137   Textual dump of actions is obtained from KexiTableDesignerInterface::simulateAlterTableExecution().
0138   Every line contains section(s): <actionname> [(<fielddebugstring>)].
0139   Example use:
0140  checkActions
0141   Insert table field "textfield" at position 1 (textfield Text(200))
0142   Remove table field "model"
0143   Insert table field "longtextfield" at position 3 (longtextfield Text(200))
0144  endActions
0145 
0146 5. Commands related to physical schema saving (altering) and checking its result
0147 
0148 * saveTableDesign
0149   Executes the final Alter Table function. Table design will be altered and data should 
0150   be preserved. After this command it is usable to run "checkTableData" test to see 
0151   whether the data looks as expected.
0152 
0153 * showTableData [clipboard]
0154   Shows current table contents in tab-separated CSV format (one row per record) 
0155   on the stderr; text is encoded in utf-8. The data is printed to the stderr.
0156   If optional "clipboard" word is present, the data is copied to clipboard instead.
0157   Table dumps can be sometimes large and hard to prepare by hand, so you can use 
0158   "clipboard" word to prepare the expected table dump by pasting the text to 
0159   a .altertable file.
0160   For details about the output format in the description "checkTableData".
0161 
0162 * checkTableData \n <block> \n endTableData
0163   Compares the current contents of table with expected contents, line by line.
0164   The data has to be in tab-separated CSV format (one row per record); 
0165   text has to be encoded in utf-8 and enclosed in " quotes. 
0166   Column names should be included as a first row.
0167   You can use showTableData command first and then copy the results to your test file for later.
0168   Example use:
0169    checkTableData
0170     ID  Name    Surname
0171     1   John    Wayne
0172     2   Al      Pacino
0173    endTableData
0174 
0175 6. Other commands.
0176 
0177 * closeWindow
0178   Closes the currently opened table designer window without asking for saving changes.
0179 
0180 * stop
0181   Stops processing immediately. For example, this can be inserted temporarily to stop testing 
0182   (with success result). This command is available in any place.
0183 
0184 * quit
0185   Executes "closeWindow" command and quits the application (with success result).
0186 
0187 6. Comments
0188 
0189 Comments can be inserted by adding # on the left hand as in bash shell 
0190 or using /* and */ for multiple rows. Empty rows are ignored.
0191 
0192 
0193 The result of executing the "altertable" test
0194 ---------------------------------------------
0195 
0196 On errors, kexialtertabletest program will show an appropriate error message with line number 
0197 where the error encountered and stop executing the tests.
0198 
0199 A given "checkSchema" command should result in "Schema check for table 'foo': OK" message.
0200 Entire test from a give .altertable file 'foo' should end with "Tests from file 'foo': OK" message.