Susumu Yata
null+****@clear*****
Thu Jul 6 16:30:54 JST 2017
Susumu Yata 2017-07-06 16:30:54 +0900 (Thu, 06 Jul 2017) New Revision: 626453e3c405f96d56f52df8fb9744c2ab13c118 https://github.com/groonga/grnci/commit/626453e3c405f96d56f52df8fb9744c2ab13c118 Message: Add a test of DB.Restore. Modified files: v2/libgrn/db_test.go Modified: v2/libgrn/db_test.go (+33 -0) =================================================================== --- v2/libgrn/db_test.go 2017-07-06 16:30:45 +0900 (06d2191) +++ v2/libgrn/db_test.go 2017-07-06 16:30:54 +0900 (2b6a18b) @@ -1,9 +1,11 @@ package libgrn import ( + "bytes" "io/ioutil" "os" "path/filepath" + "strings" "testing" "time" @@ -328,6 +330,37 @@ func TestDBNormalizerList(t *testing.T) { // } // } +func TestRestore(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 + +load --table Tbl +[ +["col"], +["Hello, world!"] +] +` + buf := new(bytes.Buffer) + n, err := db.Restore(strings.NewReader(dump), buf, true) + if err != nil { + t.Fatalf("db.Restore failed: %v", err) + } + if n != 3 { + t.Fatalf("N is wrong: n = %d", n) + } + actual := buf.String() + want := `true +true +1 +` + if actual != want { + t.Fatalf("db.Restore failed: actual = %s, want = %s", actual, want) + } +} + // func TestDBSchema(t *testing.T) { // client, err := NewHTTPClient("", nil) // if err != nil { -------------- next part -------------- HTML����������������������������...Download