Susumu Yata
null+****@clear*****
Fri Jul 7 13:00:53 JST 2017
Susumu Yata 2017-07-07 13:00:53 +0900 (Fri, 07 Jul 2017) New Revision: 7049162535a7e6f14d3d39b29d8edc80452b8d61 https://github.com/groonga/grnci/commit/7049162535a7e6f14d3d39b29d8edc80452b8d61 Message: Add tests for column_remove. GitHub: #39 Modified files: v2/libgrn/db_test.go Modified: v2/libgrn/db_test.go (+46 -17) =================================================================== --- v2/libgrn/db_test.go 2017-07-07 12:52:55 +0900 (d483356) +++ v2/libgrn/db_test.go 2017-07-07 13:00:53 +0900 (c82a149) @@ -106,24 +106,53 @@ func TestDBColumnListInvalidTable(t *testing.T) { // } // } -// func TestDBColumnRemove(t *testing.T) { -// client, err := NewHTTPClient("", nil) -// if err != nil { -// t.Skipf("NewHTTPClient failed: %v", err) -// } -// db := NewDB(client) -// defer db.Close() +func TestDBColumnRemove(t *testing.T) { + db, dir := makeDB(t) + defer removeDB(db, dir) -// result, resp, err := db.ColumnRemove("no_such_table.no_such_column") -// if err != nil { -// t.Fatalf("db.ColumnRemove failed: %v", err) -// } -// log.Printf("result = %#v", result) -// log.Printf("resp = %#v", resp) -// if err := resp.Err(); err != nil { -// log.Printf("error = %#v", err) -// } -// } + dump := `table_create Tbl TABLE_NO_KEY +column_create Tbl col COLUMN_SCALAR ShortText` + if _, err := db.Restore(strings.NewReader(dump), nil, true); err != nil { + t.Fatalf("db.Restore failed: %v", err) + } + _, resp, err := db.ColumnRemove("Tbl.col") + if err == nil { + err = resp.Err() + } + if err != nil { + t.Fatalf("db.ColumnRemove failed: %v", err) + } +} + +func TestDBColumnRemoveInvalidTable(t *testing.T) { + db, dir := makeDB(t) + defer removeDB(db, dir) + + _, resp, err := db.ColumnRemove("no_such_table.no_such_column") + if err != nil { + t.Fatalf("db.ColumnRemove failed: %v", err) + } + if resp.Err() == nil { + t.Fatalf("db.ColumnRemove wrongly succeeded") + } +} + +func TestDBColumnRemoveInvalidColumn(t *testing.T) { + db, dir := makeDB(t) + defer removeDB(db, dir) + + dump := `table_create Tbl TABLE_NO_KEY` + if _, err := db.Restore(strings.NewReader(dump), nil, true); err != nil { + t.Fatalf("db.Restore failed: %v", err) + } + _, resp, err := db.ColumnRemove("Tbl.no_such_column") + if err != nil { + t.Fatalf("db.ColumnRemove failed: %v", err) + } + if resp.Err() == nil { + t.Fatalf("db.ColumnRemove wrongly succeeded") + } +} // func TestDBDump(t *testing.T) { // client, err := NewHTTPClient("", nil) -------------- next part -------------- HTML����������������������������... 다운로드