| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- package odb
- import (
- "testing"
- "time"
- "github.com/gomodule/redigo/redis"
- "github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/require"
- "github.com/vmihailenco/msgpack/v5"
- )
- func dial() (redis.Conn, error) {
- //c, err := redis.Dial("tcp", "172.26.38.247:11001")
- c, err := redis.Dial("tcp", "127.0.0.1:11001")
- //c, err := redis.Dial("tcp", "172.20.147.7:11001")
- if err != nil {
- return nil, err
- }
- return c, nil
- }
- func Test_1(t *testing.T) {
- c, err := dial()
- assert.Nil(t, err, "Error")
- defer c.Close()
- reply, err := redis.DoWithTimeout(c, 1200*time.Second, "create", "testoo", "REPLICATION = {'class': 'SimpleStrategy', 'replication_factor': 1}")
- require.Nil(t, err, "Error")
- t.Logf("reply ==>%v \n", string(reply.([]byte)))
- }
- func Test_2(t *testing.T) {
- c, err := dial()
- assert.Nil(t, err, "Error")
- defer c.Close()
- option, _ := msgpack.Marshal(map[string]interface{}{"db": "testoo", "asterisk_keep": []string{"class", "id"}})
- reply, err := c.Do("MQL", ` select * from MillingCuttingTool where id = "MillingCuttingTool:1002"; `, option)
- require.Nil(t, err, "Error")
- t.Logf("reply ==>%v \n", string(reply.([]byte)))
- }
- func Test_3(t *testing.T) {
- c, err := dial()
- assert.Nil(t, err, "Error")
- defer c.Close()
- option, _ := msgpack.Marshal(map[string]interface{}{"db": "matrix", "asterisk_keep": []string{"class", "id"}})
- reply, err := c.Do("MQL", ` select * from MillingCuttingTool where id = "MillingCuttingTool:1002"; `, option)
- require.Nil(t, err, "Error")
- t.Logf("reply ==>%v \n", string(reply.([]byte)))
- }
|