Susumu Yata
null+****@clear*****
Thu Jul 6 14:42:53 JST 2017
Susumu Yata 2017-07-06 14:42:53 +0900 (Thu, 06 Jul 2017) New Revision: 1e29b6f7367054a6537ae407464ffe1585b32445 https://github.com/groonga/grnci/commit/1e29b6f7367054a6537ae407464ffe1585b32445 Message: Disable tests that require a server. Modified files: v2/db_test.go v2/gqtp_test.go v2/http_test.go v2/libgrn/client_test.go v2/libgrn/conn_test.go Modified: v2/db_test.go (+478 -486) =================================================================== --- v2/db_test.go 2017-07-06 14:41:19 +0900 (dc12cab) +++ v2/db_test.go 2017-07-06 14:42:53 +0900 (995747b) @@ -1,488 +1,480 @@ package grnci -import ( - "io/ioutil" - "log" - "strings" - "testing" - "time" -) - -func TestDBColumnList(t *testing.T) { - client, err := NewHTTPClient("", nil) - if err != nil { - t.Skipf("NewHTTPClient failed: %v", err) - } - db := NewDB(client) - defer db.Close() - - result, resp, err := db.ColumnList("Tbl") - if err != nil { - t.Fatalf("db.ColumnList failed: %v", err) - } - log.Printf("result = %#v", result) - log.Printf("resp = %#v", resp) - if err := resp.Err(); err != nil { - log.Printf("error = %#v", err) - } -} - -func TestDBColumnCopy(t *testing.T) { - client, err := NewHTTPClient("", nil) - if err != nil { - t.Skipf("NewHTTPClient failed: %v", err) - } - db := NewDB(client) - defer db.Close() - - result, resp, err := db.ColumnCopy("Tbl.col", "Tbl.col2") - if err != nil { - t.Fatalf("db.ColumnCopy failed: %v", err) - } - log.Printf("result = %#v", result) - log.Printf("resp = %#v", resp) - if err := resp.Err(); err != nil { - log.Printf("error = %#v", err) - } -} - -func TestDBColumnCreate(t *testing.T) { - client, err := NewHTTPClient("", nil) - if err != nil { - t.Skipf("NewHTTPClient failed: %v", err) - } - db := NewDB(client) - defer db.Close() - - result, resp, err := db.ColumnCreate("Tbl.col", "ShortText", nil) - if err != nil { - t.Fatalf("db.ColumnCreate failed: %v", err) - } - log.Printf("result = %#v", result) - log.Printf("resp = %#v", resp) - if err := resp.Err(); err != nil { - log.Printf("error = %#v", err) - } -} - -func TestDBColumnRemove(t *testing.T) { - client, err := NewHTTPClient("", nil) - if err != nil { - t.Skipf("NewHTTPClient failed: %v", err) - } - db := NewDB(client) - defer db.Close() - - 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) - } -} - -func TestDBDump(t *testing.T) { - client, err := NewHTTPClient("", nil) - if err != nil { - t.Skipf("NewHTTPClient failed: %v", err) - } - db := NewDB(client) - defer db.Close() - - result, resp, err := db.Dump(nil) - if err != nil { - t.Fatalf("db.Dump failed: %v", err) - } - body, err := ioutil.ReadAll(result) - if err != nil { - t.Fatalf("ioutil.ReadAll failed: %v", err) - } - result.Close() - log.Printf("body = %s", body) - log.Printf("resp = %#v", resp) - if err := resp.Err(); err != nil { - log.Printf("error = %#v", err) - } -} - -func TestDBLoad(t *testing.T) { - client, err := NewHTTPClient("", nil) - if err != nil { - t.Skipf("NewHTTPClient failed: %v", err) - } - db := NewDB(client) - defer db.Close() - - result, resp, err := db.Load("Tbl", strings.NewReader("[]"), nil) - if err != nil { - t.Fatalf("db.Load failed: %v", err) - } - log.Printf("result = %d", result) - log.Printf("resp = %#v", resp) - if err := resp.Err(); err != nil { - log.Printf("error = %#v", err) - } -} - -func TestDBLoadRows(t *testing.T) { - client, err := NewHTTPClient("", nil) - if err != nil { - t.Skipf("NewHTTPClient failed: %v", err) - } - db := NewDB(client) - defer db.Close() - - type Row struct { - Key string `grnci:"_key"` - Bool bool `grnci:"bool"` - Int int `grnci:"int"` - Int8 int8 `grnci:"int8"` - Int16 int16 `grnci:"int16"` - Int32 int32 `grnci:"int32"` - Int64 int64 `grnci:"int64"` - UInt uint `grnci:"uint"` - UInt8 uint8 `grnci:"uint8"` - UInt16 uint16 `grnci:"uint16"` - UInt32 uint32 `grnci:"uint32"` - UInt64 uint64 `grnci:"uint64"` - Float float64 `grnci:"float64"` - String string `grnci:"string"` - Time time.Time `grnci:"time"` - BoolSlice []bool `grnci:"bool_slice"` - IntSlice []int `grnci:"int_slice"` - Int8Slice []int8 `grnci:"int8_slice"` - Int16Slice []int16 `grnci:"int16_slice"` - Int32Slice []int32 `grnci:"int32_slice"` - Int64Slice []int64 `grnci:"int64_slice"` - UIntSlice []uint `grnci:"uint_slice"` - UInt8Slice []uint8 `grnci:"uint8_slice"` - UInt16Slice []uint16 `grnci:"uint16_slice"` - UInt32Slice []uint32 `grnci:"uint32_slice"` - UInt64Slice []uint64 `grnci:"uint64_slice"` - FloatSlice []float64 `grnci:"float64_slice"` - StringSlice []string `grnci:"string_slice"` - TimeSlice []time.Time `grnci:"time_slice"` - } - rows := []Row{ - Row{ - Key: "Apple", - Time: time.Now(), - Float: 1.23, - StringSlice: []string{"iOS", "Safari"}, - }, - Row{ - Key: "Microsoft", - Time: time.Now(), - Float: 4.56, - StringSlice: []string{"Windows", "Edge"}, - }, - } - result, resp, err := db.LoadRows("Tbl", rows, nil) - if err != nil { - t.Fatalf("db.LoadRows failed: %v", err) - } - log.Printf("result = %d", result) - log.Printf("resp = %#v", resp) - if err := resp.Err(); err != nil { - log.Printf("error = %#v", err) - } -} - -func TestDBNormalize(t *testing.T) { - client, err := NewHTTPClient("", nil) - if err != nil { - t.Skipf("NewHTTPClient failed: %v", err) - } - db := NewDB(client) - defer db.Close() - - result, resp, err := db.Normalize("NormalizerAuto", "LaTeX", []string{ - "WITH_TYPES", "WITH_CHECKS", - }) - if err != nil { - t.Fatalf("db.Normalize failed: %v", err) - } - log.Printf("result = %#v", result) - log.Printf("resp = %#v", resp) - if err := resp.Err(); err != nil { - log.Printf("error = %#v", err) - } -} - -func TestDBNormalizerList(t *testing.T) { - client, err := NewHTTPClient("", nil) - if err != nil { - t.Skipf("NewHTTPClient failed: %v", err) - } - db := NewDB(client) - defer db.Close() - - result, resp, err := db.NormalizerList() - if err != nil { - t.Fatalf("db.NormalizerList failed: %v", err) - } - log.Printf("result = %#v", result) - log.Printf("resp = %#v", resp) - if err := resp.Err(); err != nil { - log.Printf("error = %#v", err) - } -} - -func TestDBObjectList(t *testing.T) { - client, err := NewHTTPClient("", nil) - if err != nil { - t.Skipf("NewHTTPClient failed: %v", err) - } - db := NewDB(client) - defer db.Close() - - result, resp, err := db.ObjectList() - if err != nil { - t.Fatalf("db.ObjectList failed: %v", err) - } - log.Printf("result = %#v", result) - log.Printf("resp = %#v", resp) - if err := resp.Err(); err != nil { - log.Printf("error = %#v", err) - } -} - -func TestDBQuit(t *testing.T) { - client, err := NewHTTPClient("", nil) - if err != nil { - t.Skipf("NewHTTPClient failed: %v", err) - } - db := NewDB(client) - defer db.Close() - - result, resp, err := db.Quit() - if err != nil { - t.Fatalf("db.Quit failed: %v", err) - } - log.Printf("result = %#v", result) - log.Printf("resp = %#v", resp) - if err := resp.Err(); err != nil { - log.Printf("error = %#v", err) - } -} - -func TestDBSchema(t *testing.T) { - client, err := NewHTTPClient("", nil) - if err != nil { - t.Skipf("NewHTTPClient failed: %v", err) - } - db := NewDB(client) - defer db.Close() - - result, resp, err := db.Schema() - if err != nil { - t.Fatalf("db.Schema failed: %v", err) - } - log.Printf("result = %#v", result) - log.Printf("resp = %#v", resp) - if err := resp.Err(); err != nil { - log.Printf("error = %#v", err) - } -} - -func TestDBSelect(t *testing.T) { - client, err := NewHTTPClient("", nil) - if err != nil { - t.Skipf("NewHTTPClient failed: %v", err) - } - db := NewDB(client) - defer db.Close() - - result, resp, err := db.Select("Tbl", nil) - if err != nil { - t.Fatalf("db.Select failed: %v", err) - } - body, err := ioutil.ReadAll(result) - if err != nil { - t.Fatalf("ioutil.ReadAll failed: %v", err) - } - result.Close() - log.Printf("body = %s", body) - log.Printf("resp = %#v", resp) - if err := resp.Err(); err != nil { - log.Printf("error = %#v", err) - } -} - -func TestDBSelectRows(t *testing.T) { - client, err := NewHTTPClient("", nil) - if err != nil { - t.Skipf("NewHTTPClient failed: %v", err) - } - db := NewDB(client) - defer db.Close() - - type Row struct { - Key string `grnci:"_key"` - Bool bool `grnci:"bool"` - Int8 int8 `grnci:"int8"` - Int16 int16 `grnci:"int16"` - Int32 int32 `grnci:"int32"` - Int64 int64 `grnci:"int64"` - UInt8 int8 `grnci:"uint8"` - UInt16 int16 `grnci:"uint16"` - UInt32 int32 `grnci:"uint32"` - UInt64 int64 `grnci:"uint64"` - Float float64 `grnci:"float"` - String string `grnci:"string"` - Time time.Time `grnci:"time"` - TimeSlice []time.Time `grnci:"time_slice"` - } - var rows []Row - n, resp, err := db.SelectRows("Tbl", &rows, nil) - if err != nil { - t.Fatalf("db.SelectRows failed: %v", err) - } - log.Printf("n = %d", n) - log.Printf("rows = %#v", rows) - if len(rows) != 0 { - log.Printf("time = %s", rows[0].Time) - } - log.Printf("resp = %#v", resp) - if err := resp.Err(); err != nil { - log.Printf("error = %#v", err) - } -} - -func TestDBStatus(t *testing.T) { - client, err := NewHTTPClient("", nil) - if err != nil { - t.Skipf("NewHTTPClient failed: %v", err) - } - db := NewDB(client) - defer db.Close() - - result, resp, err := db.Status() - if err != nil { - t.Fatalf("db.Status failed: %v", err) - } - log.Printf("result = %#v", result) - log.Printf("resp = %#v", resp) - if err := resp.Err(); err != nil { - log.Printf("error = %#v", err) - } -} - -func TestDBTableList(t *testing.T) { - client, err := NewHTTPClient("", nil) - if err != nil { - t.Skipf("NewHTTPClient failed: %v", err) - } - db := NewDB(client) - defer db.Close() - - result, resp, err := db.TableList() - if err != nil { - t.Fatalf("db.TableList failed: %v", err) - } - log.Printf("result = %#v", result) - log.Printf("resp = %#v", resp) - if err := resp.Err(); err != nil { - log.Printf("error = %#v", err) - } -} - -func TestDBTableTokenize(t *testing.T) { - client, err := NewHTTPClient("", nil) - if err != nil { - t.Skipf("NewHTTPClient failed: %v", err) - } - db := NewDB(client) - defer db.Close() - - options := NewDBTableTokenizeOptions() - options.Mode = "ADD" - result, resp, err := db.TableTokenize("Tbl", "あいうえお", options) - if err != nil { - t.Fatalf("db.TableTokenize failed: %v", err) - } - log.Printf("result = %#v", result) - log.Printf("resp = %#v", resp) - if err := resp.Err(); err != nil { - log.Printf("error = %#v", err) - } -} - -func TestDBTokenize(t *testing.T) { - client, err := NewHTTPClient("", nil) - if err != nil { - t.Skipf("NewHTTPClient failed: %v", err) - } - db := NewDB(client) - defer db.Close() - - result, resp, err := db.Tokenize("TokenBigram", "あいうえお", nil) - if err != nil { - t.Fatalf("db.Tokenize failed: %v", err) - } - log.Printf("result = %#v", result) - log.Printf("resp = %#v", resp) - if err := resp.Err(); err != nil { - log.Printf("error = %#v", err) - } -} - -func TestDBTruncate(t *testing.T) { - client, err := NewHTTPClient("", nil) - if err != nil { - t.Skipf("NewHTTPClient failed: %v", err) - } - db := NewDB(client) - defer db.Close() - - result, resp, err := db.Truncate("no_such_target") - if err != nil { - t.Fatalf("db.Truncate failed: %v", err) - } - log.Printf("result = %#v", result) - log.Printf("resp = %#v", resp) - if err := resp.Err(); err != nil { - log.Printf("error = %#v", err) - } -} - -func TestDBTableRemove(t *testing.T) { - client, err := NewHTTPClient("", nil) - if err != nil { - t.Skipf("NewHTTPClient failed: %v", err) - } - db := NewDB(client) - defer db.Close() - - result, resp, err := db.TableRemove("no_such_table", false) - if err != nil { - t.Fatalf("db.TableRemove failed: %v", err) - } - log.Printf("result = %#v", result) - log.Printf("resp = %#v", resp) - if err := resp.Err(); err != nil { - log.Printf("error = %#v", err) - } -} - -func TestDBTokenizerList(t *testing.T) { - client, err := NewHTTPClient("", nil) - if err != nil { - t.Skipf("NewHTTPClient failed: %v", err) - } - db := NewDB(client) - defer db.Close() - - result, resp, err := db.TokenizerList() - if err != nil { - t.Fatalf("db.TokenizerList failed: %v", err) - } - log.Printf("result = %#v", result) - log.Printf("resp = %#v", resp) - if err := resp.Err(); err != nil { - log.Printf("error = %#v", err) - } -} +// func TestDBColumnList(t *testing.T) { +// client, err := NewHTTPClient("", nil) +// if err != nil { +// t.Skipf("NewHTTPClient failed: %v", err) +// } +// db := NewDB(client) +// defer db.Close() + +// result, resp, err := db.ColumnList("Tbl") +// if err != nil { +// t.Fatalf("db.ColumnList failed: %v", err) +// } +// log.Printf("result = %#v", result) +// log.Printf("resp = %#v", resp) +// if err := resp.Err(); err != nil { +// log.Printf("error = %#v", err) +// } +// } + +// func TestDBColumnCopy(t *testing.T) { +// client, err := NewHTTPClient("", nil) +// if err != nil { +// t.Skipf("NewHTTPClient failed: %v", err) +// } +// db := NewDB(client) +// defer db.Close() + +// result, resp, err := db.ColumnCopy("Tbl.col", "Tbl.col2") +// if err != nil { +// t.Fatalf("db.ColumnCopy failed: %v", err) +// } +// log.Printf("result = %#v", result) +// log.Printf("resp = %#v", resp) +// if err := resp.Err(); err != nil { +// log.Printf("error = %#v", err) +// } +// } + +// func TestDBColumnCreate(t *testing.T) { +// client, err := NewHTTPClient("", nil) +// if err != nil { +// t.Skipf("NewHTTPClient failed: %v", err) +// } +// db := NewDB(client) +// defer db.Close() + +// result, resp, err := db.ColumnCreate("Tbl.col", "ShortText", nil) +// if err != nil { +// t.Fatalf("db.ColumnCreate failed: %v", err) +// } +// log.Printf("result = %#v", result) +// log.Printf("resp = %#v", resp) +// if err := resp.Err(); err != nil { +// log.Printf("error = %#v", err) +// } +// } + +// func TestDBColumnRemove(t *testing.T) { +// client, err := NewHTTPClient("", nil) +// if err != nil { +// t.Skipf("NewHTTPClient failed: %v", err) +// } +// db := NewDB(client) +// defer db.Close() + +// 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) +// } +// } + +// func TestDBDump(t *testing.T) { +// client, err := NewHTTPClient("", nil) +// if err != nil { +// t.Skipf("NewHTTPClient failed: %v", err) +// } +// db := NewDB(client) +// defer db.Close() + +// result, resp, err := db.Dump(nil) +// if err != nil { +// t.Fatalf("db.Dump failed: %v", err) +// } +// body, err := ioutil.ReadAll(result) +// if err != nil { +// t.Fatalf("ioutil.ReadAll failed: %v", err) +// } +// result.Close() +// log.Printf("body = %s", body) +// log.Printf("resp = %#v", resp) +// if err := resp.Err(); err != nil { +// log.Printf("error = %#v", err) +// } +// } + +// func TestDBLoad(t *testing.T) { +// client, err := NewHTTPClient("", nil) +// if err != nil { +// t.Skipf("NewHTTPClient failed: %v", err) +// } +// db := NewDB(client) +// defer db.Close() + +// result, resp, err := db.Load("Tbl", strings.NewReader("[]"), nil) +// if err != nil { +// t.Fatalf("db.Load failed: %v", err) +// } +// log.Printf("result = %d", result) +// log.Printf("resp = %#v", resp) +// if err := resp.Err(); err != nil { +// log.Printf("error = %#v", err) +// } +// } + +// func TestDBLoadRows(t *testing.T) { +// client, err := NewHTTPClient("", nil) +// if err != nil { +// t.Skipf("NewHTTPClient failed: %v", err) +// } +// db := NewDB(client) +// defer db.Close() + +// type Row struct { +// Key string `grnci:"_key"` +// Bool bool `grnci:"bool"` +// Int int `grnci:"int"` +// Int8 int8 `grnci:"int8"` +// Int16 int16 `grnci:"int16"` +// Int32 int32 `grnci:"int32"` +// Int64 int64 `grnci:"int64"` +// UInt uint `grnci:"uint"` +// UInt8 uint8 `grnci:"uint8"` +// UInt16 uint16 `grnci:"uint16"` +// UInt32 uint32 `grnci:"uint32"` +// UInt64 uint64 `grnci:"uint64"` +// Float float64 `grnci:"float64"` +// String string `grnci:"string"` +// Time time.Time `grnci:"time"` +// BoolSlice []bool `grnci:"bool_slice"` +// IntSlice []int `grnci:"int_slice"` +// Int8Slice []int8 `grnci:"int8_slice"` +// Int16Slice []int16 `grnci:"int16_slice"` +// Int32Slice []int32 `grnci:"int32_slice"` +// Int64Slice []int64 `grnci:"int64_slice"` +// UIntSlice []uint `grnci:"uint_slice"` +// UInt8Slice []uint8 `grnci:"uint8_slice"` +// UInt16Slice []uint16 `grnci:"uint16_slice"` +// UInt32Slice []uint32 `grnci:"uint32_slice"` +// UInt64Slice []uint64 `grnci:"uint64_slice"` +// FloatSlice []float64 `grnci:"float64_slice"` +// StringSlice []string `grnci:"string_slice"` +// TimeSlice []time.Time `grnci:"time_slice"` +// } +// rows := []Row{ +// Row{ +// Key: "Apple", +// Time: time.Now(), +// Float: 1.23, +// StringSlice: []string{"iOS", "Safari"}, +// }, +// Row{ +// Key: "Microsoft", +// Time: time.Now(), +// Float: 4.56, +// StringSlice: []string{"Windows", "Edge"}, +// }, +// } +// result, resp, err := db.LoadRows("Tbl", rows, nil) +// if err != nil { +// t.Fatalf("db.LoadRows failed: %v", err) +// } +// log.Printf("result = %d", result) +// log.Printf("resp = %#v", resp) +// if err := resp.Err(); err != nil { +// log.Printf("error = %#v", err) +// } +// } + +// func TestDBNormalize(t *testing.T) { +// client, err := NewHTTPClient("", nil) +// if err != nil { +// t.Skipf("NewHTTPClient failed: %v", err) +// } +// db := NewDB(client) +// defer db.Close() + +// result, resp, err := db.Normalize("NormalizerAuto", "LaTeX", []string{ +// "WITH_TYPES", "WITH_CHECKS", +// }) +// if err != nil { +// t.Fatalf("db.Normalize failed: %v", err) +// } +// log.Printf("result = %#v", result) +// log.Printf("resp = %#v", resp) +// if err := resp.Err(); err != nil { +// log.Printf("error = %#v", err) +// } +// } + +// func TestDBNormalizerList(t *testing.T) { +// client, err := NewHTTPClient("", nil) +// if err != nil { +// t.Skipf("NewHTTPClient failed: %v", err) +// } +// db := NewDB(client) +// defer db.Close() + +// result, resp, err := db.NormalizerList() +// if err != nil { +// t.Fatalf("db.NormalizerList failed: %v", err) +// } +// log.Printf("result = %#v", result) +// log.Printf("resp = %#v", resp) +// if err := resp.Err(); err != nil { +// log.Printf("error = %#v", err) +// } +// } + +// func TestDBObjectList(t *testing.T) { +// client, err := NewHTTPClient("", nil) +// if err != nil { +// t.Skipf("NewHTTPClient failed: %v", err) +// } +// db := NewDB(client) +// defer db.Close() + +// result, resp, err := db.ObjectList() +// if err != nil { +// t.Fatalf("db.ObjectList failed: %v", err) +// } +// log.Printf("result = %#v", result) +// log.Printf("resp = %#v", resp) +// if err := resp.Err(); err != nil { +// log.Printf("error = %#v", err) +// } +// } + +// func TestDBQuit(t *testing.T) { +// client, err := NewHTTPClient("", nil) +// if err != nil { +// t.Skipf("NewHTTPClient failed: %v", err) +// } +// db := NewDB(client) +// defer db.Close() + +// result, resp, err := db.Quit() +// if err != nil { +// t.Fatalf("db.Quit failed: %v", err) +// } +// log.Printf("result = %#v", result) +// log.Printf("resp = %#v", resp) +// if err := resp.Err(); err != nil { +// log.Printf("error = %#v", err) +// } +// } + +// func TestDBSchema(t *testing.T) { +// client, err := NewHTTPClient("", nil) +// if err != nil { +// t.Skipf("NewHTTPClient failed: %v", err) +// } +// db := NewDB(client) +// defer db.Close() + +// result, resp, err := db.Schema() +// if err != nil { +// t.Fatalf("db.Schema failed: %v", err) +// } +// log.Printf("result = %#v", result) +// log.Printf("resp = %#v", resp) +// if err := resp.Err(); err != nil { +// log.Printf("error = %#v", err) +// } +// } + +// func TestDBSelect(t *testing.T) { +// client, err := NewHTTPClient("", nil) +// if err != nil { +// t.Skipf("NewHTTPClient failed: %v", err) +// } +// db := NewDB(client) +// defer db.Close() + +// result, resp, err := db.Select("Tbl", nil) +// if err != nil { +// t.Fatalf("db.Select failed: %v", err) +// } +// body, err := ioutil.ReadAll(result) +// if err != nil { +// t.Fatalf("ioutil.ReadAll failed: %v", err) +// } +// result.Close() +// log.Printf("body = %s", body) +// log.Printf("resp = %#v", resp) +// if err := resp.Err(); err != nil { +// log.Printf("error = %#v", err) +// } +// } + +// func TestDBSelectRows(t *testing.T) { +// client, err := NewHTTPClient("", nil) +// if err != nil { +// t.Skipf("NewHTTPClient failed: %v", err) +// } +// db := NewDB(client) +// defer db.Close() + +// type Row struct { +// Key string `grnci:"_key"` +// Bool bool `grnci:"bool"` +// Int8 int8 `grnci:"int8"` +// Int16 int16 `grnci:"int16"` +// Int32 int32 `grnci:"int32"` +// Int64 int64 `grnci:"int64"` +// UInt8 int8 `grnci:"uint8"` +// UInt16 int16 `grnci:"uint16"` +// UInt32 int32 `grnci:"uint32"` +// UInt64 int64 `grnci:"uint64"` +// Float float64 `grnci:"float"` +// String string `grnci:"string"` +// Time time.Time `grnci:"time"` +// TimeSlice []time.Time `grnci:"time_slice"` +// } +// var rows []Row +// n, resp, err := db.SelectRows("Tbl", &rows, nil) +// if err != nil { +// t.Fatalf("db.SelectRows failed: %v", err) +// } +// log.Printf("n = %d", n) +// log.Printf("rows = %#v", rows) +// if len(rows) != 0 { +// log.Printf("time = %s", rows[0].Time) +// } +// log.Printf("resp = %#v", resp) +// if err := resp.Err(); err != nil { +// log.Printf("error = %#v", err) +// } +// } + +// func TestDBStatus(t *testing.T) { +// client, err := NewHTTPClient("", nil) +// if err != nil { +// t.Skipf("NewHTTPClient failed: %v", err) +// } +// db := NewDB(client) +// defer db.Close() + +// result, resp, err := db.Status() +// if err != nil { +// t.Fatalf("db.Status failed: %v", err) +// } +// log.Printf("result = %#v", result) +// log.Printf("resp = %#v", resp) +// if err := resp.Err(); err != nil { +// log.Printf("error = %#v", err) +// } +// } + +// func TestDBTableList(t *testing.T) { +// client, err := NewHTTPClient("", nil) +// if err != nil { +// t.Skipf("NewHTTPClient failed: %v", err) +// } +// db := NewDB(client) +// defer db.Close() + +// result, resp, err := db.TableList() +// if err != nil { +// t.Fatalf("db.TableList failed: %v", err) +// } +// log.Printf("result = %#v", result) +// log.Printf("resp = %#v", resp) +// if err := resp.Err(); err != nil { +// log.Printf("error = %#v", err) +// } +// } + +// func TestDBTableTokenize(t *testing.T) { +// client, err := NewHTTPClient("", nil) +// if err != nil { +// t.Skipf("NewHTTPClient failed: %v", err) +// } +// db := NewDB(client) +// defer db.Close() + +// options := NewDBTableTokenizeOptions() +// options.Mode = "ADD" +// result, resp, err := db.TableTokenize("Tbl", "あいうえお", options) +// if err != nil { +// t.Fatalf("db.TableTokenize failed: %v", err) +// } +// log.Printf("result = %#v", result) +// log.Printf("resp = %#v", resp) +// if err := resp.Err(); err != nil { +// log.Printf("error = %#v", err) +// } +// } + +// func TestDBTokenize(t *testing.T) { +// client, err := NewHTTPClient("", nil) +// if err != nil { +// t.Skipf("NewHTTPClient failed: %v", err) +// } +// db := NewDB(client) +// defer db.Close() + +// result, resp, err := db.Tokenize("TokenBigram", "あいうえお", nil) +// if err != nil { +// t.Fatalf("db.Tokenize failed: %v", err) +// } +// log.Printf("result = %#v", result) +// log.Printf("resp = %#v", resp) +// if err := resp.Err(); err != nil { +// log.Printf("error = %#v", err) +// } +// } + +// func TestDBTruncate(t *testing.T) { +// client, err := NewHTTPClient("", nil) +// if err != nil { +// t.Skipf("NewHTTPClient failed: %v", err) +// } +// db := NewDB(client) +// defer db.Close() + +// result, resp, err := db.Truncate("no_such_target") +// if err != nil { +// t.Fatalf("db.Truncate failed: %v", err) +// } +// log.Printf("result = %#v", result) +// log.Printf("resp = %#v", resp) +// if err := resp.Err(); err != nil { +// log.Printf("error = %#v", err) +// } +// } + +// func TestDBTableRemove(t *testing.T) { +// client, err := NewHTTPClient("", nil) +// if err != nil { +// t.Skipf("NewHTTPClient failed: %v", err) +// } +// db := NewDB(client) +// defer db.Close() + +// result, resp, err := db.TableRemove("no_such_table", false) +// if err != nil { +// t.Fatalf("db.TableRemove failed: %v", err) +// } +// log.Printf("result = %#v", result) +// log.Printf("resp = %#v", resp) +// if err := resp.Err(); err != nil { +// log.Printf("error = %#v", err) +// } +// } + +// func TestDBTokenizerList(t *testing.T) { +// client, err := NewHTTPClient("", nil) +// if err != nil { +// t.Skipf("NewHTTPClient failed: %v", err) +// } +// db := NewDB(client) +// defer db.Close() + +// result, resp, err := db.TokenizerList() +// if err != nil { +// t.Fatalf("db.TokenizerList failed: %v", err) +// } +// log.Printf("result = %#v", result) +// log.Printf("resp = %#v", resp) +// if err := resp.Err(); err != nil { +// log.Printf("error = %#v", err) +// } +// } Modified: v2/gqtp_test.go (+92 -96) =================================================================== --- v2/gqtp_test.go 2017-07-06 14:41:19 +0900 (a012671) +++ v2/gqtp_test.go 2017-07-06 14:42:53 +0900 (b61bfb7) @@ -1,110 +1,106 @@ package grnci import ( - "io" - "io/ioutil" - "log" - "strings" "testing" ) -func TestGQTPConn(t *testing.T) { - type Pair struct { - Command string - Body string - } - pairs := []Pair{ - // Pair{"no_such_command", ""}, - Pair{"status", ""}, - Pair{`table_create Tbl TABLE_PAT_KEY ShortText`, ""}, - Pair{`column_create Tbl Col COLUMN_SCALAR Int32`, ""}, - Pair{`load --table Tbl --values '[["_key"],["test"]]'`, ""}, - Pair{`load --table Tbl --values '[["_key"],["test" invalid_format]]'`, ""}, - Pair{"load --table Tbl", `[["_key"],["test"]]`}, - Pair{"load --table Tbl", `[["_key"],["test" invalid_format]]`}, - Pair{"select --table Tbl", ""}, - Pair{"dump", ""}, - } +// func TestGQTPConn(t *testing.T) { +// type Pair struct { +// Command string +// Body string +// } +// pairs := []Pair{ +// // Pair{"no_such_command", ""}, +// Pair{"status", ""}, +// Pair{`table_create Tbl TABLE_PAT_KEY ShortText`, ""}, +// Pair{`column_create Tbl Col COLUMN_SCALAR Int32`, ""}, +// Pair{`load --table Tbl --values '[["_key"],["test"]]'`, ""}, +// Pair{`load --table Tbl --values '[["_key"],["test" invalid_format]]'`, ""}, +// Pair{"load --table Tbl", `[["_key"],["test"]]`}, +// Pair{"load --table Tbl", `[["_key"],["test" invalid_format]]`}, +// Pair{"select --table Tbl", ""}, +// Pair{"dump", ""}, +// } - conn, err := DialGQTP("") - if err != nil { - t.Skipf("DialGQTP failed: %v", err) - } - defer conn.Close() +// conn, err := DialGQTP("") +// if err != nil { +// t.Skipf("DialGQTP failed: %v", err) +// } +// defer conn.Close() - for _, pair := range pairs { - var body io.Reader - if pair.Body != "" { - body = strings.NewReader(pair.Body) - } - log.Printf("command = %s", pair.Command) - resp, err := conn.Exec(pair.Command, body) - if err != nil { - t.Fatalf("conn.Exec failed: %v", err) - } - result, err := ioutil.ReadAll(resp) - if err != nil { - t.Fatalf("ioutil.ReadAll failed: %v", err) - } - log.Printf("start = %v, elapsed = %v", resp.Start(), resp.Elapsed()) - log.Printf("result = %s", result) - if err := resp.Err(); err != nil { - log.Printf("err = %v", err) - } - if err := resp.Close(); err != nil { - t.Fatalf("resp.Close failed: %v", err) - } - } -} +// for _, pair := range pairs { +// var body io.Reader +// if pair.Body != "" { +// body = strings.NewReader(pair.Body) +// } +// log.Printf("command = %s", pair.Command) +// resp, err := conn.Exec(pair.Command, body) +// if err != nil { +// t.Fatalf("conn.Exec failed: %v", err) +// } +// result, err := ioutil.ReadAll(resp) +// if err != nil { +// t.Fatalf("ioutil.ReadAll failed: %v", err) +// } +// log.Printf("start = %v, elapsed = %v", resp.Start(), resp.Elapsed()) +// log.Printf("result = %s", result) +// if err := resp.Err(); err != nil { +// log.Printf("err = %v", err) +// } +// if err := resp.Close(); err != nil { +// t.Fatalf("resp.Close failed: %v", err) +// } +// } +// } -func TestGQTPClient(t *testing.T) { - type Pair struct { - Command string - Body string - } - pairs := []Pair{ - // Pair{"no_such_command", ""}, - Pair{"status", ""}, - Pair{`table_create Tbl TABLE_PAT_KEY ShortText`, ""}, - Pair{`column_create Tbl Col COLUMN_SCALAR Int32`, ""}, - Pair{`load --table Tbl --values '[["_key"],["test"]]'`, ""}, - Pair{`load --table Tbl --values '[["_key"],["test" invalid_format]]'`, ""}, - Pair{"load --table Tbl", `[["_key"],["test"]]`}, - Pair{"load --table Tbl", `[["_key"],["test" invalid_format]]`}, - Pair{"select --table Tbl", ""}, - Pair{"dump", ""}, - } +// func TestGQTPClient(t *testing.T) { +// type Pair struct { +// Command string +// Body string +// } +// pairs := []Pair{ +// // Pair{"no_such_command", ""}, +// Pair{"status", ""}, +// Pair{`table_create Tbl TABLE_PAT_KEY ShortText`, ""}, +// Pair{`column_create Tbl Col COLUMN_SCALAR Int32`, ""}, +// Pair{`load --table Tbl --values '[["_key"],["test"]]'`, ""}, +// Pair{`load --table Tbl --values '[["_key"],["test" invalid_format]]'`, ""}, +// Pair{"load --table Tbl", `[["_key"],["test"]]`}, +// Pair{"load --table Tbl", `[["_key"],["test" invalid_format]]`}, +// Pair{"select --table Tbl", ""}, +// Pair{"dump", ""}, +// } - client, err := NewGQTPClient("") - if err != nil { - t.Skipf("NewGQTPClient failed: %v", err) - } - defer client.Close() +// client, err := NewGQTPClient("") +// if err != nil { +// t.Skipf("NewGQTPClient failed: %v", err) +// } +// defer client.Close() - for _, pair := range pairs { - var body io.Reader - if pair.Body != "" { - body = strings.NewReader(pair.Body) - } - log.Printf("command = %s", pair.Command) - resp, err := client.Exec(pair.Command, body) - if err != nil { - t.Fatalf("conn.Exec failed: %v", err) - } - result, err := ioutil.ReadAll(resp) - if err != nil { - t.Fatalf("ioutil.ReadAll failed: %v", err) - } - log.Printf("start = %v, elapsed = %v", resp.Start(), resp.Elapsed()) - log.Printf("result = %s", result) - if err := resp.Err(); err != nil { - log.Printf("err = %v", err) - } - if err := resp.Close(); err != nil { - t.Fatalf("resp.Close failed: %v", err) - } - } -} +// for _, pair := range pairs { +// var body io.Reader +// if pair.Body != "" { +// body = strings.NewReader(pair.Body) +// } +// log.Printf("command = %s", pair.Command) +// resp, err := client.Exec(pair.Command, body) +// if err != nil { +// t.Fatalf("conn.Exec failed: %v", err) +// } +// result, err := ioutil.ReadAll(resp) +// if err != nil { +// t.Fatalf("ioutil.ReadAll failed: %v", err) +// } +// log.Printf("start = %v, elapsed = %v", resp.Start(), resp.Elapsed()) +// log.Printf("result = %s", result) +// if err := resp.Err(); err != nil { +// log.Printf("err = %v", err) +// } +// if err := resp.Close(); err != nil { +// t.Fatalf("resp.Close failed: %v", err) +// } +// } +// } func TestGQTPConnHandler(t *testing.T) { var i interface{} = &GQTPConn{} Modified: v2/http_test.go (+46 -50) =================================================================== --- v2/http_test.go 2017-07-06 14:41:19 +0900 (0cc8707) +++ v2/http_test.go 2017-07-06 14:42:53 +0900 (07b08d6) @@ -1,61 +1,57 @@ package grnci import ( - "io" - "io/ioutil" - "log" - "strings" "testing" ) -func TestHTTPClient(t *testing.T) { - type Pair struct { - Command string - Body string - } - pairs := []Pair{ - // Pair{"no_such_command", ""}, - Pair{"status", ""}, - Pair{`table_create Tbl TABLE_PAT_KEY ShortText`, ""}, - Pair{`column_create Tbl Col COLUMN_SCALAR Int32`, ""}, - Pair{`load --table Tbl --values '[["_key"],["test"]]'`, ""}, - Pair{`load --table Tbl --values '[["_key"],["test" invalid_format]]'`, ""}, - Pair{"load --table Tbl", `[["_key"],["test"]]`}, - Pair{"load --table Tbl", `[["_key"],["test" invalid_format]]`}, - Pair{"select --table Tbl", ""}, - Pair{"dump", ""}, - } +// func TestHTTPClient(t *testing.T) { +// type Pair struct { +// Command string +// Body string +// } +// pairs := []Pair{ +// // Pair{"no_such_command", ""}, +// Pair{"status", ""}, +// Pair{`table_create Tbl TABLE_PAT_KEY ShortText`, ""}, +// Pair{`column_create Tbl Col COLUMN_SCALAR Int32`, ""}, +// Pair{`load --table Tbl --values '[["_key"],["test"]]'`, ""}, +// Pair{`load --table Tbl --values '[["_key"],["test" invalid_format]]'`, ""}, +// Pair{"load --table Tbl", `[["_key"],["test"]]`}, +// Pair{"load --table Tbl", `[["_key"],["test" invalid_format]]`}, +// Pair{"select --table Tbl", ""}, +// Pair{"dump", ""}, +// } - client, err := NewHTTPClient("", nil) - if err != nil { - t.Skipf("NewHTTPClient failed: %v", err) - } - defer client.Close() +// client, err := NewHTTPClient("", nil) +// if err != nil { +// t.Skipf("NewHTTPClient failed: %v", err) +// } +// defer client.Close() - for _, pair := range pairs { - var body io.Reader - if pair.Body != "" { - body = strings.NewReader(pair.Body) - } - log.Printf("command = %s", pair.Command) - resp, err := client.Exec(pair.Command, body) - if err != nil { - t.Fatalf("conn.Exec failed: %v", err) - } - result, err := ioutil.ReadAll(resp) - if err != nil { - t.Fatalf("ioutil.ReadAll failed: %v", err) - } - log.Printf("start = %v, elapsed = %v", resp.Start(), resp.Elapsed()) - log.Printf("result = %s", result) - if err := resp.Err(); err != nil { - log.Printf("err = %v", err) - } - if err := resp.Close(); err != nil { - t.Fatalf("resp.Close failed: %v", err) - } - } -} +// for _, pair := range pairs { +// var body io.Reader +// if pair.Body != "" { +// body = strings.NewReader(pair.Body) +// } +// log.Printf("command = %s", pair.Command) +// resp, err := client.Exec(pair.Command, body) +// if err != nil { +// t.Fatalf("conn.Exec failed: %v", err) +// } +// result, err := ioutil.ReadAll(resp) +// if err != nil { +// t.Fatalf("ioutil.ReadAll failed: %v", err) +// } +// log.Printf("start = %v, elapsed = %v", resp.Start(), resp.Elapsed()) +// log.Printf("result = %s", result) +// if err := resp.Err(); err != nil { +// log.Printf("err = %v", err) +// } +// if err := resp.Close(); err != nil { +// t.Fatalf("resp.Close failed: %v", err) +// } +// } +// } func TestHTTPClientHandler(t *testing.T) { var i interface{} = &HTTPClient{} Modified: v2/libgrn/client_test.go (+46 -46) =================================================================== --- v2/libgrn/client_test.go 2017-07-06 14:41:19 +0900 (634186f) +++ v2/libgrn/client_test.go 2017-07-06 14:42:53 +0900 (bbc190f) @@ -10,54 +10,54 @@ import ( "github.com/groonga/grnci/v2" ) -func TestClientGQTP(t *testing.T) { - type Pair struct { - Command string - Body string - } - pairs := []Pair{ - // Pair{"no_such_command", ""}, - Pair{"status", ""}, - Pair{`table_create Tbl TABLE_PAT_KEY ShortText`, ""}, - Pair{`column_create Tbl Col COLUMN_SCALAR Int32`, ""}, - Pair{`load --table Tbl --values '[["_key"],["test"]]'`, ""}, - Pair{`load --table Tbl --values '[["_key"],["test" invalid_format]]'`, ""}, - Pair{"load --table Tbl", `[["_key"],["test"]]`}, - Pair{"load --table Tbl", `[["_key"],["test" invalid_format]]`}, - Pair{"select --table Tbl", ""}, - Pair{"dump", ""}, - } +// func TestClientGQTP(t *testing.T) { +// type Pair struct { +// Command string +// Body string +// } +// pairs := []Pair{ +// // Pair{"no_such_command", ""}, +// Pair{"status", ""}, +// Pair{`table_create Tbl TABLE_PAT_KEY ShortText`, ""}, +// Pair{`column_create Tbl Col COLUMN_SCALAR Int32`, ""}, +// Pair{`load --table Tbl --values '[["_key"],["test"]]'`, ""}, +// Pair{`load --table Tbl --values '[["_key"],["test" invalid_format]]'`, ""}, +// Pair{"load --table Tbl", `[["_key"],["test"]]`}, +// Pair{"load --table Tbl", `[["_key"],["test" invalid_format]]`}, +// Pair{"select --table Tbl", ""}, +// Pair{"dump", ""}, +// } - client, err := DialClient("") - if err != nil { - t.Skipf("DialClient failed: %v", err) - } - defer client.Close() +// client, err := DialClient("") +// if err != nil { +// t.Skipf("DialClient failed: %v", err) +// } +// defer client.Close() - for _, pair := range pairs { - var body io.Reader - if pair.Body != "" { - body = strings.NewReader(pair.Body) - } - log.Printf("command = %s", pair.Command) - resp, err := client.Exec(pair.Command, body) - if err != nil { - t.Fatalf("client.Exec failed: %v", err) - } - result, err := ioutil.ReadAll(resp) - if err != nil { - t.Fatalf("ioutil.ReadAll failed: %v", err) - } - log.Printf("start = %v, elapsed = %v", resp.Start(), resp.Elapsed()) - log.Printf("result = %s", result) - if err := resp.Err(); err != nil { - log.Printf("err = %v", err) - } - if err := resp.Close(); err != nil { - t.Fatalf("resp.Close failed: %v", err) - } - } -} +// for _, pair := range pairs { +// var body io.Reader +// if pair.Body != "" { +// body = strings.NewReader(pair.Body) +// } +// log.Printf("command = %s", pair.Command) +// resp, err := client.Exec(pair.Command, body) +// if err != nil { +// t.Fatalf("client.Exec failed: %v", err) +// } +// result, err := ioutil.ReadAll(resp) +// if err != nil { +// t.Fatalf("ioutil.ReadAll failed: %v", err) +// } +// log.Printf("start = %v, elapsed = %v", resp.Start(), resp.Elapsed()) +// log.Printf("result = %s", result) +// if err := resp.Err(); err != nil { +// log.Printf("err = %v", err) +// } +// if err := resp.Close(); err != nil { +// t.Fatalf("resp.Close failed: %v", err) +// } +// } +// } func TestClientDB(t *testing.T) { type Pair struct { Modified: v2/libgrn/conn_test.go (+46 -46) =================================================================== --- v2/libgrn/conn_test.go 2017-07-06 14:41:19 +0900 (87a5b25) +++ v2/libgrn/conn_test.go 2017-07-06 14:42:53 +0900 (a3c8d69) @@ -10,54 +10,54 @@ import ( "github.com/groonga/grnci/v2" ) -func TestConnGQTP(t *testing.T) { - type Pair struct { - Command string - Body string - } - pairs := []Pair{ - // Pair{"no_such_command", ""}, - Pair{"status", ""}, - Pair{`table_create Tbl TABLE_PAT_KEY ShortText`, ""}, - Pair{`column_create Tbl Col COLUMN_SCALAR Int32`, ""}, - Pair{`load --table Tbl --values '[["_key"],["test"]]'`, ""}, - Pair{`load --table Tbl --values '[["_key"],["test" invalid_format]]'`, ""}, - Pair{"load --table Tbl", `[["_key"],["test"]]`}, - Pair{"load --table Tbl", `[["_key"],["test" invalid_format]]`}, - Pair{"select --table Tbl", ""}, - Pair{"dump", ""}, - } +// func TestConnGQTP(t *testing.T) { +// type Pair struct { +// Command string +// Body string +// } +// pairs := []Pair{ +// // Pair{"no_such_command", ""}, +// Pair{"status", ""}, +// Pair{`table_create Tbl TABLE_PAT_KEY ShortText`, ""}, +// Pair{`column_create Tbl Col COLUMN_SCALAR Int32`, ""}, +// Pair{`load --table Tbl --values '[["_key"],["test"]]'`, ""}, +// Pair{`load --table Tbl --values '[["_key"],["test" invalid_format]]'`, ""}, +// Pair{"load --table Tbl", `[["_key"],["test"]]`}, +// Pair{"load --table Tbl", `[["_key"],["test" invalid_format]]`}, +// Pair{"select --table Tbl", ""}, +// Pair{"dump", ""}, +// } - conn, err := Dial("") - if err != nil { - t.Skipf("Dial failed: %v", err) - } - defer conn.Close() +// conn, err := Dial("") +// if err != nil { +// t.Skipf("Dial failed: %v", err) +// } +// defer conn.Close() - for _, pair := range pairs { - var body io.Reader - if pair.Body != "" { - body = strings.NewReader(pair.Body) - } - log.Printf("command = %s", pair.Command) - resp, err := conn.Exec(pair.Command, body) - if err != nil { - t.Fatalf("conn.Exec failed: %v", err) - } - result, err := ioutil.ReadAll(resp) - if err != nil { - t.Fatalf("ioutil.ReadAll failed: %v", err) - } - log.Printf("start = %v, elapsed = %v", resp.Start(), resp.Elapsed()) - log.Printf("result = %s", result) - if err := resp.Err(); err != nil { - log.Printf("err = %v", err) - } - if err := resp.Close(); err != nil { - t.Fatalf("resp.Close failed: %v", err) - } - } -} +// for _, pair := range pairs { +// var body io.Reader +// if pair.Body != "" { +// body = strings.NewReader(pair.Body) +// } +// log.Printf("command = %s", pair.Command) +// resp, err := conn.Exec(pair.Command, body) +// if err != nil { +// t.Fatalf("conn.Exec failed: %v", err) +// } +// result, err := ioutil.ReadAll(resp) +// if err != nil { +// t.Fatalf("ioutil.ReadAll failed: %v", err) +// } +// log.Printf("start = %v, elapsed = %v", resp.Start(), resp.Elapsed()) +// log.Printf("result = %s", result) +// if err := resp.Err(); err != nil { +// log.Printf("err = %v", err) +// } +// if err := resp.Close(); err != nil { +// t.Fatalf("resp.Close failed: %v", err) +// } +// } +// } func TestConnDB(t *testing.T) { type Pair struct { -------------- next part -------------- HTML����������������������������... Télécharger