1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-26 19:21:03 +03:00

Tweak transaction API.

This commit is contained in:
Vladimir Mihailenco
2016-05-02 15:54:15 +03:00
parent 033a4de2fb
commit 092698ecd3
8 changed files with 138 additions and 161 deletions

View File

@ -65,16 +65,15 @@ var _ = Describe("Client", func() {
Expect(client.Ping().Err()).NotTo(HaveOccurred())
})
It("should close multi without closing the client", func() {
tx, err := client.Watch()
Expect(err).NotTo(HaveOccurred())
Expect(tx.Close()).NotTo(HaveOccurred())
_, err = tx.Exec(func() error {
tx.Ping()
return nil
It("should close Tx without closing the client", func() {
err := client.Watch(func(tx *redis.Tx) error {
_, err := tx.MultiExec(func() error {
tx.Ping()
return nil
})
return err
})
Expect(err).To(MatchError("redis: client is closed"))
Expect(err).NotTo(HaveOccurred())
Expect(client.Ping().Err()).NotTo(HaveOccurred())
})
@ -96,13 +95,6 @@ var _ = Describe("Client", func() {
Expect(pubsub.Close()).NotTo(HaveOccurred())
})
It("should close multi when client is closed", func() {
tx, err := client.Watch()
Expect(err).NotTo(HaveOccurred())
Expect(client.Close()).NotTo(HaveOccurred())
Expect(tx.Close()).NotTo(HaveOccurred())
})
It("should close pipeline when client is closed", func() {
pipeline := client.Pipeline()
Expect(client.Close()).NotTo(HaveOccurred())