Details
-
Bug
-
Resolution: Fixed
-
Major
-
2.0.2
-
None
-
None
-
1
Description
After moving to v2 i noticed all my tests were failing saying "Not connected to a bucket". I was reusing the cluster connection but with buckets i was just getting them via cluster.Bucket() each time. So after breaking out a completely separate test I found out it was because I need to reuse the bucket connection. Now unfortunately it wasn't clear in the docs that this was the case. With all that being said the idea that if for whatever reason i didnt reuse the bucket connection to me sounds like a decent bug. Below is the code i used to replicate this issue.
func TestSimple(t *testing.T) { cluster, err := gocb.Connect( "localhost", gocb.ClusterOptions{ Username: "Administrator", Password: "password", }) if err != nil { panic(err) } |
bucket := cluster.Bucket("vault") collection := bucket.DefaultCollection() |
// Upsert Document upsertData := map[string]string{"name": "mike"} upsertResult, err := collection.Upsert("my-document", upsertData, &gocb.UpsertOptions{}) if err != nil { panic(err) } fmt.Println(upsertResult) |
bucket2 := cluster.Bucket("vault") collection2 := bucket2.DefaultCollection() |
// Get Document getResult, err := collection2.Get("my-document", &gocb.GetOptions{}) if err != nil { panic(err) } fmt.Println(getResult)} |