options_test.go 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. package goSam
  2. import "testing"
  3. func TestOptionAddrString(t *testing.T) {
  4. client, err := NewClientFromOptions(SetAddr("127.0.0.1:7656"), SetDebug(true))
  5. if err != nil {
  6. t.Fatalf("NewDefaultClient() Error: %q\n", err)
  7. }
  8. if err := client.Close(); err != nil {
  9. t.Fatalf("client.Close() Error: %q\n", err)
  10. }
  11. }
  12. func TestOptionAddrStringLh(t *testing.T) {
  13. client, err := NewClientFromOptions(SetAddr("localhost:7656"), SetDebug(true))
  14. if err != nil {
  15. t.Fatalf("NewDefaultClient() Error: %q\n", err)
  16. }
  17. if err := client.Close(); err != nil {
  18. t.Fatalf("client.Close() Error: %q\n", err)
  19. }
  20. }
  21. func TestOptionAddrSlice(t *testing.T) {
  22. client, err := NewClientFromOptions(SetAddr("127.0.0.1", "7656"), SetDebug(true))
  23. if err != nil {
  24. t.Fatalf("NewDefaultClient() Error: %q\n", err)
  25. }
  26. if err := client.Close(); err != nil {
  27. t.Fatalf("client.Close() Error: %q\n", err)
  28. }
  29. }
  30. func TestOptionAddrMixedSlice(t *testing.T) {
  31. client, err := NewClientFromOptions(SetAddrMixed("127.0.0.1", 7656), SetDebug(true))
  32. if err != nil {
  33. t.Fatalf("NewDefaultClient() Error: %q\n", err)
  34. }
  35. if err := client.Close(); err != nil {
  36. t.Fatalf("client.Close() Error: %q\n", err)
  37. }
  38. }
  39. func TestOptionHost(t *testing.T) {
  40. client, err := NewClientFromOptions(SetHost("127.0.0.1"), SetDebug(true))
  41. if err != nil {
  42. t.Fatalf("NewDefaultClient() Error: %q\n", err)
  43. }
  44. if err := client.Close(); err != nil {
  45. t.Fatalf("client.Close() Error: %q\n", err)
  46. }
  47. }
  48. func TestOptionPort(t *testing.T) {
  49. client, err := NewClientFromOptions(SetPort("7656"), SetDebug(true))
  50. if err != nil {
  51. t.Fatalf("NewDefaultClient() Error: %q\n", err)
  52. }
  53. if err := client.Close(); err != nil {
  54. t.Fatalf("client.Close() Error: %q\n", err)
  55. }
  56. }
  57. func TestOptionPortInt(t *testing.T) {
  58. client, err := NewClientFromOptions(SetPortInt(7656), SetDebug(true))
  59. if err != nil {
  60. t.Fatalf("NewDefaultClient() Error: %q\n", err)
  61. }
  62. if err := client.Close(); err != nil {
  63. t.Fatalf("client.Close() Error: %q\n", err)
  64. }
  65. }
  66. func TestOptionDebug(t *testing.T) {
  67. client, err := NewClientFromOptions(SetDebug(true))
  68. if err != nil {
  69. t.Fatalf("NewDefaultClient() Error: %q\n", err)
  70. }
  71. if err := client.Close(); err != nil {
  72. t.Fatalf("client.Close() Error: %q\n", err)
  73. }
  74. }
  75. func TestOptionInLength(t *testing.T) {
  76. client, err := NewClientFromOptions(SetInLength(3), SetDebug(true))
  77. client.inlength()
  78. if err != nil {
  79. t.Fatalf("NewDefaultClient() Error: %q\n", err)
  80. }
  81. if err := client.Close(); err != nil {
  82. t.Fatalf("client.Close() Error: %q\n", err)
  83. }
  84. }
  85. func TestOptionOutLength(t *testing.T) {
  86. client, err := NewClientFromOptions(SetInLength(3), SetDebug(true))
  87. client.outlength()
  88. if err != nil {
  89. t.Fatalf("NewDefaultClient() Error: %q\n", err)
  90. }
  91. if err := client.Close(); err != nil {
  92. t.Fatalf("client.Close() Error: %q\n", err)
  93. }
  94. }
  95. func TestOptionInVariance(t *testing.T) {
  96. client, err := NewClientFromOptions(SetInVariance(1), SetDebug(true))
  97. client.invariance()
  98. if err != nil {
  99. t.Fatalf("NewDefaultClient() Error: %q\n", err)
  100. }
  101. if err := client.Close(); err != nil {
  102. t.Fatalf("client.Close() Error: %q\n", err)
  103. }
  104. }
  105. func TestOptionOutVariance(t *testing.T) {
  106. client, err := NewClientFromOptions(SetOutVariance(1), SetDebug(true))
  107. client.outvariance()
  108. if err != nil {
  109. t.Fatalf("NewDefaultClient() Error: %q\n", err)
  110. }
  111. if err := client.Close(); err != nil {
  112. t.Fatalf("client.Close() Error: %q\n", err)
  113. }
  114. }
  115. func TestOptionInQuantity(t *testing.T) {
  116. client, err := NewClientFromOptions(SetInQuantity(6), SetDebug(true))
  117. client.inquantity()
  118. if err != nil {
  119. t.Fatalf("NewDefaultClient() Error: %q\n", err)
  120. }
  121. if err := client.Close(); err != nil {
  122. t.Fatalf("client.Close() Error: %q\n", err)
  123. }
  124. }
  125. func TestOptionOutQuantity(t *testing.T) {
  126. client, err := NewClientFromOptions(SetOutQuantity(6), SetDebug(true))
  127. client.outquantity()
  128. if err != nil {
  129. t.Fatalf("NewDefaultClient() Error: %q\n", err)
  130. }
  131. if err := client.Close(); err != nil {
  132. t.Fatalf("client.Close() Error: %q\n", err)
  133. }
  134. }
  135. func TestOptionInBackups(t *testing.T) {
  136. client, err := NewClientFromOptions(SetInBackups(5), SetDebug(true))
  137. client.inbackups()
  138. if err != nil {
  139. t.Fatalf("NewDefaultClient() Error: %q\n", err)
  140. }
  141. if err := client.Close(); err != nil {
  142. t.Fatalf("client.Close() Error: %q\n", err)
  143. }
  144. }
  145. func TestOptionOutBackups(t *testing.T) {
  146. client, err := NewClientFromOptions(SetOutBackups(5), SetDebug(true))
  147. client.outbackups()
  148. if err != nil {
  149. t.Fatalf("NewDefaultClient() Error: %q\n", err)
  150. }
  151. if err := client.Close(); err != nil {
  152. t.Fatalf("client.Close() Error: %q\n", err)
  153. }
  154. }
  155. func TestOptionEncryptLease(t *testing.T) {
  156. client, err := NewClientFromOptions(SetEncrypt(true), SetDebug(true))
  157. if err != nil {
  158. t.Fatalf("NewDefaultClient() Error: %q\n", err)
  159. }
  160. if err := client.Close(); err != nil {
  161. t.Fatalf("client.Close() Error: %q\n", err)
  162. }
  163. }
  164. func TestOptionUnpublishedLease(t *testing.T) {
  165. client, err := NewClientFromOptions(SetUnpublished(true), SetDebug(true))
  166. if err != nil {
  167. t.Fatalf("NewDefaultClient() Error: %q\n", err)
  168. }
  169. if err := client.Close(); err != nil {
  170. t.Fatalf("client.Close() Error: %q\n", err)
  171. }
  172. }
  173. func TestOptionReduceIdle(t *testing.T) {
  174. client, err := NewClientFromOptions(SetReduceIdle(true), SetDebug(true))
  175. if err != nil {
  176. t.Fatalf("NewDefaultClient() Error: %q\n", err)
  177. }
  178. if err := client.Close(); err != nil {
  179. t.Fatalf("client.Close() Error: %q\n", err)
  180. }
  181. }
  182. func TestOptionReduceIdleTime(t *testing.T) {
  183. client, err := NewClientFromOptions(SetReduceIdleTime(300001), SetDebug(true))
  184. if err != nil {
  185. t.Fatalf("NewDefaultClient() Error: %q\n", err)
  186. }
  187. if err := client.Close(); err != nil {
  188. t.Fatalf("client.Close() Error: %q\n", err)
  189. }
  190. }
  191. func TestOptionReduceIdleCount(t *testing.T) {
  192. client, err := NewClientFromOptions(SetReduceIdleQuantity(4), SetDebug(true))
  193. if err != nil {
  194. t.Fatalf("NewDefaultClient() Error: %q\n", err)
  195. }
  196. if err := client.Close(); err != nil {
  197. t.Fatalf("client.Close() Error: %q\n", err)
  198. }
  199. }
  200. func TestOptionCloseIdle(t *testing.T) {
  201. client, err := NewClientFromOptions(SetCloseIdle(true), SetDebug(true))
  202. if err != nil {
  203. t.Fatalf("NewDefaultClient() Error: %q\n", err)
  204. }
  205. if err := client.Close(); err != nil {
  206. t.Fatalf("client.Close() Error: %q\n", err)
  207. }
  208. }
  209. func TestOptionCloseIdleTime(t *testing.T) {
  210. client, err := NewClientFromOptions(SetCloseIdleTime(300001), SetDebug(true))
  211. if err != nil {
  212. t.Fatalf("NewDefaultClient() Error: %q\n", err)
  213. }
  214. if err := client.Close(); err != nil {
  215. t.Fatalf("client.Close() Error: %q\n", err)
  216. }
  217. }