-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdjondb_network_test.go
53 lines (46 loc) · 1.04 KB
/
djondb_network_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package djondbgo
import (
"testing"
)
func TestInsert(t *testing.T) {
net := CreateNetwork();
net.connect("localhost", 1243)
/* Header **/
net.writeString("3.6.33333")
/* Command Type */
net.writeInt(0) // INSERT
/* options */
var options map[string]interface{}
options = make(map[string]interface{})
net.writeBSON(options) // Options
/* data */
net.writeString("testdb")
net.writeString("testns")
var data map[string]interface{}
data = make(map[string]interface{})
data["name"] = "John"
data["lastName"] = "Smith"
net.writeBSON(data)
net.flush()
t.Logf("Done");
}
func TestShowDbs(t *testing.T) {
net := CreateNetwork();
net.connect("localhost", 1243)
/* Header **/
net.writeString("3.6.33333")
/* Command Type */
net.writeInt(6) // SHOWDBS
/* options */
var options map[string]interface{}
options = make(map[string]interface{})
net.writeBSON(options) // Options
net.flush()
dbs := net.readInt()
t.Logf("Dbs: %d", dbs)
db := net.readString()
t.Logf("DB " + db)
db = net.readString()
t.Logf("DB " + db)
t.Logf("Done");
}