1
0
mirror of https://github.com/redis/go-redis.git synced 2025-06-12 14:21:52 +03:00

Rename Multi to Tx to better reflect the purpose. Fixes #194.

This commit is contained in:
Vladimir Mihailenco
2016-04-09 11:23:58 +03:00
parent b351402995
commit 7a03514d7f
7 changed files with 124 additions and 149 deletions

View File

@ -4,9 +4,6 @@ import (
"encoding/json"
"fmt"
"reflect"
"strconv"
"sync"
"testing"
"time"
. "github.com/onsi/ginkgo"
@ -2551,63 +2548,6 @@ var _ = Describe("Commands", func() {
})
Describe("watch/unwatch", func() {
It("should WatchUnwatch", func() {
var C, N = 10, 1000
if testing.Short() {
N = 100
}
err := client.Set("key", "0", 0).Err()
Expect(err).NotTo(HaveOccurred())
wg := &sync.WaitGroup{}
for i := 0; i < C; i++ {
wg.Add(1)
go func() {
defer GinkgoRecover()
defer wg.Done()
multi := client.Multi()
defer multi.Close()
for j := 0; j < N; j++ {
val, err := multi.Watch("key").Result()
Expect(err).NotTo(HaveOccurred())
Expect(val).To(Equal("OK"))
val, err = multi.Get("key").Result()
Expect(err).NotTo(HaveOccurred())
Expect(val).NotTo(Equal(redis.Nil))
num, err := strconv.ParseInt(val, 10, 64)
Expect(err).NotTo(HaveOccurred())
cmds, err := multi.Exec(func() error {
multi.Set("key", strconv.FormatInt(num+1, 10), 0)
return nil
})
if err == redis.TxFailedErr {
j--
continue
}
Expect(err).NotTo(HaveOccurred())
Expect(cmds).To(HaveLen(1))
Expect(cmds[0].Err()).NotTo(HaveOccurred())
}
}()
}
wg.Wait()
val, err := client.Get("key").Int64()
Expect(err).NotTo(HaveOccurred())
Expect(val).To(Equal(int64(C * N)))
})
})
Describe("Geo add and radius search", func() {
BeforeEach(func() {
geoAdd := client.GeoAdd(