Susumu Yata
null+****@clear*****
Thu Sep 14 15:09:34 JST 2017
Susumu Yata 2017-09-14 15:09:34 +0900 (Thu, 14 Sep 2017) New Revision: 1ff9a569228eaeceaebddf1c70c4dfbe3fc139f1 https://github.com/groonga/grnci/commit/1ff9a569228eaeceaebddf1c70c4dfbe3fc139f1 Message: Add tests for DB.ObjectInspect. Ref: #39 Modified files: v2/libgrn/db_test.go Modified: v2/libgrn/db_test.go (+61 -0) =================================================================== --- v2/libgrn/db_test.go 2017-09-14 15:05:30 +0900 (9c15452) +++ v2/libgrn/db_test.go 2017-09-14 15:09:34 +0900 (85b46a0) @@ -951,6 +951,67 @@ func TestDBObjectExistInvalidName(t *testing.T) { } } +func TestDBObjectInspect(t *testing.T) { + db, dir := makeDB(t) + defer removeDB(db, dir) + + result, err := db.ObjectInspect("") + if err != nil { + t.Fatalf("db.ObjectInspect failed: %v", err) + } + if _, ok := result.(*grnci.DBObjectDatabase); !ok { + t.Fatalf("db.ObjectInspect failed: result = %#v", result) + } +} + +func TestDBObjectInspectType(t *testing.T) { + db, dir := makeDB(t) + defer removeDB(db, dir) + + result, err := db.ObjectInspect("Bool") + if err != nil { + t.Fatalf("db.ObjectInspect failed: %v", err) + } + if _, ok := result.(*grnci.DBObjectType); !ok { + t.Fatalf("db.ObjectInspect failed: result = %#v", result) + } +} + +func TestDBObjectInspectTable(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) + } + result, err := db.ObjectInspect("Tbl") + if err != nil { + t.Fatalf("db.ObjectInspect failed: %v", err) + } + if _, ok := result.(*grnci.DBObjectTable); !ok { + t.Fatalf("db.ObjectInspect failed: result = %#v", result) + } +} + +func TestDBObjectInspectColumn(t *testing.T) { + db, dir := makeDB(t) + defer removeDB(db, dir) + + 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) + } + result, err := db.ObjectInspect("Tbl.col") + if err != nil { + t.Fatalf("db.ObjectInspect failed: %v", err) + } + if _, ok := result.(*grnci.DBObjectColumn); !ok { + t.Fatalf("db.ObjectInspect failed: result = %#v", result) + } +} + func TestDBObjectList(t *testing.T) { db, dir := makeDB(t) defer removeDB(db, dir) -------------- next part -------------- HTML����������������������������... URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20170914/90aa4cc1/attachment-0001.htm