susumu.yata
null+****@clear*****
Thu May 7 17:15:48 JST 2015
susumu.yata 2015-05-07 17:15:48 +0900 (Thu, 07 May 2015) New Revision: d12cc61babfa347658fcbfa96ea3e676a15325ac https://github.com/groonga/grnxx/commit/d12cc61babfa347658fcbfa96ea3e676a15325ac Message: Gnx: separate tests for GrnDB.CreateTable(). Modified files: go3/gnx/grn_test.go Modified: go3/gnx/grn_test.go (+87 -10) =================================================================== --- go3/gnx/grn_test.go 2015-05-07 12:25:07 +0900 (cc610b1) +++ go3/gnx/grn_test.go 2015-05-07 17:15:48 +0900 (0ccd939) @@ -91,45 +91,122 @@ func testGrnDBCreateTableWithKey(t *testing.T, keyType string) { func testGrnDBCreateTableWithValue(t *testing.T, valueType string) { options := NewTableOptions() + options.TableType = PatTable options.ValueType = valueType dirPath, _, db, _ := createTempGrnTable(t, "Table", options) removeTempGrnDB(t, dirPath, db) } -func testGrnDBCreateTableRef(t *testing.T, keyType string) { +func testGrnDBCreateTableWithRefKey(t *testing.T, keyType string) { options := NewTableOptions() options.TableType = PatTable options.KeyType = keyType - dirPath, _, db, _ := createTempGrnTable(t, "Table", options) + dirPath, _, db, _ := createTempGrnTable(t, "To", options) + defer removeTempGrnDB(t, dirPath, db) + + options = NewTableOptions() + options.TableType = PatTable + options.KeyType = "To" + _, err := db.CreateTable("From", options) + if err != nil { + t.Fatalf("GrnDB.CreateTable() failed: %v", err) + } +} + +func testGrnDBCreateTableWithRefValue(t *testing.T, keyType string) { + options := NewTableOptions() + options.TableType = PatTable + options.KeyType = keyType + dirPath, _, db, _ := createTempGrnTable(t, "To", options) defer removeTempGrnDB(t, dirPath, db) - options.KeyType = "Table" - _, err := db.CreateTable("Table2", options) + options = NewTableOptions() + options.ValueType = "" + _, err := db.CreateTable("From", options) if err != nil { t.Fatalf("GrnDB.CreateTable() failed: %v", err) } } -func TestGrnDBCreateTable(t *testing.T) { +func TestGrnDBCreateTableWithoutKeyValue(t *testing.T) { dirPath, _, db, _ := createTempGrnTable(t, "Table", nil) removeTempGrnDB(t, dirPath, db) +} +func TestGrnDBCreateTableWithBoolKey(t *testing.T) { testGrnDBCreateTableWithKey(t, "Bool") +} + +func TestGrnDBCreateTableWithIntKey(t *testing.T) { testGrnDBCreateTableWithKey(t, "Int") +} + +func TestGrnDBCreateTableWithFloatKey(t *testing.T) { testGrnDBCreateTableWithKey(t, "Float") +} + +func TestGrnDBCreateTableWithGeoPointKey(t *testing.T) { testGrnDBCreateTableWithKey(t, "GeoPoint") +} + +func TestGrnDBCreateTableWithTextKey(t *testing.T) { testGrnDBCreateTableWithKey(t, "Text") +} +func TestGrnDBCreateTableWithBoolValue(t *testing.T) { testGrnDBCreateTableWithValue(t, "Bool") +} + +func TestGrnDBCreateTableWithIntValue(t *testing.T) { testGrnDBCreateTableWithValue(t, "Int") +} + +func TestGrnDBCreateTableWithFloatValue(t *testing.T) { testGrnDBCreateTableWithValue(t, "Float") +} + +func TestGrnDBCreateTableWithGeoPointValue(t *testing.T) { testGrnDBCreateTableWithValue(t, "GeoPoint") +} + +func TestGrnDBCreateTableWithBoolRefKey(t *testing.T) { + testGrnDBCreateTableWithRefKey(t, "Bool") +} + +func TestGrnDBCreateTableWithIntRefKey(t *testing.T) { + testGrnDBCreateTableWithRefKey(t, "Int") +} + +func TestGrnDBCreateTableWithFloatRefKey(t *testing.T) { + testGrnDBCreateTableWithRefKey(t, "Float") +} + +func TestGrnDBCreateTableWithGeoPointRefKey(t *testing.T) { + testGrnDBCreateTableWithRefKey(t, "GeoPoint") +} + +func TestGrnDBCreateTableWithTextRefKey(t *testing.T) { + testGrnDBCreateTableWithRefKey(t, "Text") +} + +func TestGrnDBCreateTableWithBoolRefValue(t *testing.T) { + testGrnDBCreateTableWithRefValue(t, "Bool") +} + +func TestGrnDBCreateTableWithIntRefValue(t *testing.T) { + testGrnDBCreateTableWithRefValue(t, "Int") +} + +func TestGrnDBCreateTableWithFloatRefValue(t *testing.T) { + testGrnDBCreateTableWithRefValue(t, "Float") +} + +func TestGrnDBCreateTableWithGeoPointRefValue(t *testing.T) { + testGrnDBCreateTableWithRefValue(t, "GeoPoint") +} - testGrnDBCreateTableRef(t, "Bool") - testGrnDBCreateTableRef(t, "Int") - testGrnDBCreateTableRef(t, "Float") - testGrnDBCreateTableRef(t, "GeoPoint") - testGrnDBCreateTableRef(t, "Text") +func TestGrnDBCreateTableWithTextRefValue(t *testing.T) { + testGrnDBCreateTableWithRefValue(t, "Text") } func generateRandomKey(keyType string) interface{} { -------------- next part -------------- HTML����������������������������... Descargar