result.go 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. package redis
  2. import "time"
  3. // NewCmdResult returns a Cmd initialised with val and err for testing.
  4. func NewCmdResult(val interface{}, err error) *Cmd {
  5. var cmd Cmd
  6. cmd.val = val
  7. cmd.SetErr(err)
  8. return &cmd
  9. }
  10. // NewSliceResult returns a SliceCmd initialised with val and err for testing.
  11. func NewSliceResult(val []interface{}, err error) *SliceCmd {
  12. var cmd SliceCmd
  13. cmd.val = val
  14. cmd.SetErr(err)
  15. return &cmd
  16. }
  17. // NewStatusResult returns a StatusCmd initialised with val and err for testing.
  18. func NewStatusResult(val string, err error) *StatusCmd {
  19. var cmd StatusCmd
  20. cmd.val = val
  21. cmd.SetErr(err)
  22. return &cmd
  23. }
  24. // NewIntResult returns an IntCmd initialised with val and err for testing.
  25. func NewIntResult(val int64, err error) *IntCmd {
  26. var cmd IntCmd
  27. cmd.val = val
  28. cmd.SetErr(err)
  29. return &cmd
  30. }
  31. // NewDurationResult returns a DurationCmd initialised with val and err for testing.
  32. func NewDurationResult(val time.Duration, err error) *DurationCmd {
  33. var cmd DurationCmd
  34. cmd.val = val
  35. cmd.SetErr(err)
  36. return &cmd
  37. }
  38. // NewBoolResult returns a BoolCmd initialised with val and err for testing.
  39. func NewBoolResult(val bool, err error) *BoolCmd {
  40. var cmd BoolCmd
  41. cmd.val = val
  42. cmd.SetErr(err)
  43. return &cmd
  44. }
  45. // NewStringResult returns a StringCmd initialised with val and err for testing.
  46. func NewStringResult(val string, err error) *StringCmd {
  47. var cmd StringCmd
  48. cmd.val = val
  49. cmd.SetErr(err)
  50. return &cmd
  51. }
  52. // NewFloatResult returns a FloatCmd initialised with val and err for testing.
  53. func NewFloatResult(val float64, err error) *FloatCmd {
  54. var cmd FloatCmd
  55. cmd.val = val
  56. cmd.SetErr(err)
  57. return &cmd
  58. }
  59. // NewStringSliceResult returns a StringSliceCmd initialised with val and err for testing.
  60. func NewStringSliceResult(val []string, err error) *StringSliceCmd {
  61. var cmd StringSliceCmd
  62. cmd.val = val
  63. cmd.SetErr(err)
  64. return &cmd
  65. }
  66. // NewBoolSliceResult returns a BoolSliceCmd initialised with val and err for testing.
  67. func NewBoolSliceResult(val []bool, err error) *BoolSliceCmd {
  68. var cmd BoolSliceCmd
  69. cmd.val = val
  70. cmd.SetErr(err)
  71. return &cmd
  72. }
  73. // NewStringStringMapResult returns a StringStringMapCmd initialised with val and err for testing.
  74. func NewStringStringMapResult(val map[string]string, err error) *StringStringMapCmd {
  75. var cmd StringStringMapCmd
  76. cmd.val = val
  77. cmd.SetErr(err)
  78. return &cmd
  79. }
  80. // NewStringIntMapCmdResult returns a StringIntMapCmd initialised with val and err for testing.
  81. func NewStringIntMapCmdResult(val map[string]int64, err error) *StringIntMapCmd {
  82. var cmd StringIntMapCmd
  83. cmd.val = val
  84. cmd.SetErr(err)
  85. return &cmd
  86. }
  87. // NewTimeCmdResult returns a TimeCmd initialised with val and err for testing.
  88. func NewTimeCmdResult(val time.Time, err error) *TimeCmd {
  89. var cmd TimeCmd
  90. cmd.val = val
  91. cmd.SetErr(err)
  92. return &cmd
  93. }
  94. // NewZSliceCmdResult returns a ZSliceCmd initialised with val and err for testing.
  95. func NewZSliceCmdResult(val []Z, err error) *ZSliceCmd {
  96. var cmd ZSliceCmd
  97. cmd.val = val
  98. cmd.SetErr(err)
  99. return &cmd
  100. }
  101. // NewZWithKeyCmdResult returns a NewZWithKeyCmd initialised with val and err for testing.
  102. func NewZWithKeyCmdResult(val *ZWithKey, err error) *ZWithKeyCmd {
  103. var cmd ZWithKeyCmd
  104. cmd.val = val
  105. cmd.SetErr(err)
  106. return &cmd
  107. }
  108. // NewScanCmdResult returns a ScanCmd initialised with val and err for testing.
  109. func NewScanCmdResult(keys []string, cursor uint64, err error) *ScanCmd {
  110. var cmd ScanCmd
  111. cmd.page = keys
  112. cmd.cursor = cursor
  113. cmd.SetErr(err)
  114. return &cmd
  115. }
  116. // NewClusterSlotsCmdResult returns a ClusterSlotsCmd initialised with val and err for testing.
  117. func NewClusterSlotsCmdResult(val []ClusterSlot, err error) *ClusterSlotsCmd {
  118. var cmd ClusterSlotsCmd
  119. cmd.val = val
  120. cmd.SetErr(err)
  121. return &cmd
  122. }
  123. // NewGeoLocationCmdResult returns a GeoLocationCmd initialised with val and err for testing.
  124. func NewGeoLocationCmdResult(val []GeoLocation, err error) *GeoLocationCmd {
  125. var cmd GeoLocationCmd
  126. cmd.locations = val
  127. cmd.SetErr(err)
  128. return &cmd
  129. }
  130. // NewGeoPosCmdResult returns a GeoPosCmd initialised with val and err for testing.
  131. func NewGeoPosCmdResult(val []*GeoPos, err error) *GeoPosCmd {
  132. var cmd GeoPosCmd
  133. cmd.val = val
  134. cmd.SetErr(err)
  135. return &cmd
  136. }
  137. // NewCommandsInfoCmdResult returns a CommandsInfoCmd initialised with val and err for testing.
  138. func NewCommandsInfoCmdResult(val map[string]*CommandInfo, err error) *CommandsInfoCmd {
  139. var cmd CommandsInfoCmd
  140. cmd.val = val
  141. cmd.SetErr(err)
  142. return &cmd
  143. }
  144. // NewXMessageSliceCmdResult returns a XMessageSliceCmd initialised with val and err for testing.
  145. func NewXMessageSliceCmdResult(val []XMessage, err error) *XMessageSliceCmd {
  146. var cmd XMessageSliceCmd
  147. cmd.val = val
  148. cmd.SetErr(err)
  149. return &cmd
  150. }
  151. // NewXStreamSliceCmdResult returns a XStreamSliceCmd initialised with val and err for testing.
  152. func NewXStreamSliceCmdResult(val []XStream, err error) *XStreamSliceCmd {
  153. var cmd XStreamSliceCmd
  154. cmd.val = val
  155. cmd.SetErr(err)
  156. return &cmd
  157. }