@@ -1633,6 +1633,32 @@ var _ = Describe("Commands", func() {
16331633			Expect (strLen .Err ()).NotTo (HaveOccurred ())
16341634			Expect (strLen .Val ()).To (Equal (int64 (0 )))
16351635		})
1636+ 
1637+ 		It ("should Copy" , func () {
1638+ 			set  :=  client .Set (ctx , "key" , "hello" , 0 )
1639+ 			Expect (set .Err ()).NotTo (HaveOccurred ())
1640+ 			Expect (set .Val ()).To (Equal ("OK" ))
1641+ 
1642+ 			copy  :=  client .Copy (ctx , "key" , "newKey" , redisOptions ().DB , false )
1643+ 			Expect (copy .Err ()).NotTo (HaveOccurred ())
1644+ 			Expect (copy .Val ()).To (Equal (int64 (1 )))
1645+ 
1646+ 			// Value is available by both keys now 
1647+ 			getOld  :=  client .Get (ctx , "key" )
1648+ 			Expect (getOld .Err ()).NotTo (HaveOccurred ())
1649+ 			Expect (getOld .Val ()).To (Equal ("hello" ))
1650+ 			getNew  :=  client .Get (ctx , "newKey" )
1651+ 			Expect (getNew .Err ()).NotTo (HaveOccurred ())
1652+ 			Expect (getNew .Val ()).To (Equal ("hello" ))
1653+ 
1654+ 			// Overwriting an existing key should not succeed 
1655+ 			overwrite  :=  client .Copy (ctx , "newKey" , "key" , redisOptions ().DB , false )
1656+ 			Expect (overwrite .Val ()).To (Equal (int64 (0 )))
1657+ 
1658+ 			// Overwrite is allowed when replace=rue 
1659+ 			replace  :=  client .Copy (ctx , "newKey" , "key" , redisOptions ().DB , true )
1660+ 			Expect (replace .Val ()).To (Equal (int64 (1 )))
1661+ 		})
16361662	})
16371663
16381664	Describe ("hashes" , func () {
0 commit comments