func TestFileTest(t *testing.T) { dbi, err := NewMongo("localhost") if err != nil { panic(err) } fmt.Printf("Testing") u, _ := uuid.NewV4() file_id := u.String() finfo := agro_pb.FileInfo{ Name: proto.String("README"), Id: proto.String(file_id), } w, _ := os.Getwd() fmt.Printf("Dis: %s\n", w) data, _ := ioutil.ReadFile("../../../README") dbi.CreateFile(context.Background(), &finfo) fmt.Printf("Sending: %s\n", data) packet := agro_pb.DataBlock{ Id: proto.String(file_id), Start: proto.Int64(0), Len: proto.Int64(int64(len(data))), Data: data, } dbi.WriteFile(context.Background(), &packet) dbi.CommitFile(context.Background(), &agro_pb.FileID{Id: proto.String(file_id)}) info, _ := dbi.GetFileInfo(context.Background(), &agro_pb.FileID{Id: proto.String(file_id)}) fmt.Printf("FileSize: %d\n", *info.Size) block, _ := dbi.ReadFile(context.Background(), &agro_pb.ReadRequest{ Id: proto.String(file_id), Start: proto.Int64(0), Size: info.Size, }) fmt.Printf("ReadOut:%d '%s'\n", *block.Len, string(block.Data)) }
func TestDocument(t *testing.T) { doc := agro_pb.Document{ Id: proto.String("test"), Fields: []*agro_pb.Field{ &agro_pb.Field{Path: []string{"hello"}, Value: &agro_pb.Field_FloatValue{FloatValue: 35.0}}, }, } dbi, err := NewMongo("localhost") if err != nil { t.Error("DB Failure") panic(err) } t.Log("Testing") fmt.Print("Testing2") dbi.CreateDoc(context.Background(), &doc) out, _ := dbi.GetDoc(context.Background(), &agro_pb.FileID{Id: proto.String("test")}) log.Print("output: ", out) }