/libstorage/api/tests/tests_suite.go

https://github.com/rexray/rexray · Go · 316 lines · 122 code · 99 blank · 95 comment · 2 complexity · 98944d8ad60213cc64d457db49d718f1 MD5 · raw file

  1. package tests
  2. import (
  3. "errors"
  4. "fmt"
  5. "path"
  6. "github.com/onsi/ginkgo"
  7. "github.com/onsi/gomega"
  8. gomegaTypes "github.com/onsi/gomega/types"
  9. )
  10. // Done is part of the Ginkgo DSL
  11. type Done ginkgo.Done
  12. // Benchmarker is part of the Ginkgo DSL
  13. type Benchmarker ginkgo.Benchmarker
  14. // GinkgoWriter is part of the Ginkgo DSL
  15. var GinkgoWriter = ginkgo.GinkgoWriter
  16. // GinkgoParallelNode is part of the Ginkgo DSL
  17. var GinkgoParallelNode = ginkgo.GinkgoParallelNode
  18. // GinkgoT is part of the Ginkgo DSL
  19. var GinkgoT = ginkgo.GinkgoT
  20. // CurrentGinkgoTestDescription is part of the Ginkgo DSL
  21. var CurrentGinkgoTestDescription = ginkgo.CurrentGinkgoTestDescription
  22. // RunSpecs is part of the Ginkgo DSL
  23. var RunSpecs = ginkgo.RunSpecs
  24. // RunSpecsWithDefaultAndCustomReporters is part of the Ginkgo DSL
  25. var RunSpecsWithDefaultAndCustomReporters = ginkgo.RunSpecsWithDefaultAndCustomReporters
  26. // RunSpecsWithCustomReporters is part of the Ginkgo DSL
  27. var RunSpecsWithCustomReporters = ginkgo.RunSpecsWithCustomReporters
  28. // Skip is part of the Ginkgo DSL
  29. var Skip = ginkgo.Skip
  30. // Fail is part of the Ginkgo DSL
  31. var Fail = ginkgo.Fail
  32. // GinkgoRecover is part of the Ginkgo DSL
  33. var GinkgoRecover = ginkgo.GinkgoRecover
  34. // Describe is part of the Ginkgo DSL
  35. var Describe = ginkgo.Describe
  36. // FDescribe is part of the Ginkgo DSL
  37. var FDescribe = ginkgo.FDescribe
  38. // PDescribe is part of the Ginkgo DSL
  39. var PDescribe = ginkgo.PDescribe
  40. // XDescribe is part of the Ginkgo DSL
  41. var XDescribe = ginkgo.XDescribe
  42. // Context is part of the Ginkgo DSL
  43. var Context = ginkgo.Context
  44. // FContext is part of the Ginkgo DSL
  45. var FContext = ginkgo.FContext
  46. // PContext is part of the Ginkgo DSL
  47. var PContext = ginkgo.PContext
  48. // XContext is part of the Ginkgo DSL
  49. var XContext = ginkgo.XContext
  50. // It is part of the Ginkgo DSL
  51. var It = ginkgo.It
  52. // FIt is part of the Ginkgo DSL
  53. var FIt = ginkgo.FIt
  54. // PIt is part of the Ginkgo DSL
  55. var PIt = ginkgo.PIt
  56. // XIt is part of the Ginkgo DSL
  57. var XIt = ginkgo.XIt
  58. // Specify is part of the Ginkgo DSL
  59. var Specify = ginkgo.Specify
  60. // FSpecify is part of the Ginkgo DSL
  61. var FSpecify = ginkgo.FSpecify
  62. // PSpecify is part of the Ginkgo DSL
  63. var PSpecify = ginkgo.PSpecify
  64. // XSpecify is part of the Ginkgo DSL
  65. var XSpecify = ginkgo.XSpecify
  66. // By is part of the Ginkgo DSL
  67. var By = ginkgo.By
  68. // Measure is part of the Ginkgo DSL
  69. var Measure = ginkgo.Measure
  70. // FMeasure is part of the Ginkgo DSL
  71. var FMeasure = ginkgo.FMeasure
  72. // PMeasure is part of the Ginkgo DSL
  73. var PMeasure = ginkgo.PMeasure
  74. // XMeasure is part of the Ginkgo DSL
  75. var XMeasure = ginkgo.XMeasure
  76. // BeforeSuite is part of the Ginkgo DSL
  77. var BeforeSuite = ginkgo.BeforeSuite
  78. // AfterSuite is part of the Ginkgo DSL
  79. var AfterSuite = ginkgo.AfterSuite
  80. // SynchronizedBeforeSuite is part of the Ginkgo DSL
  81. var SynchronizedBeforeSuite = ginkgo.SynchronizedBeforeSuite
  82. // SynchronizedAfterSuite is part of the Ginkgo DSL
  83. var SynchronizedAfterSuite = ginkgo.SynchronizedAfterSuite
  84. // BeforeEach is part of the Ginkgo DSL
  85. var BeforeEach = ginkgo.BeforeEach
  86. // JustBeforeEach is part of the Ginkgo DSL
  87. var JustBeforeEach = ginkgo.JustBeforeEach
  88. // AfterEach is part of the Ginkgo DSL
  89. var AfterEach = ginkgo.AfterEach
  90. // Declarations for Gomega DSL
  91. // RegisterFailHandler is part of the Ginkgo DSL
  92. var RegisterFailHandler = gomega.RegisterFailHandler
  93. // RegisterTestingT is part of the Ginkgo DSL
  94. var RegisterTestingT = gomega.RegisterTestingT
  95. // InterceptGomegaFailures is part of the Ginkgo DSL
  96. var InterceptGomegaFailures = gomega.InterceptGomegaFailures
  97. // Ω is part of the Ginkgo DSL
  98. var Ω = gomega.Ω
  99. // Expect is part of the Ginkgo DSL
  100. var Expect = gomega.Expect
  101. // ExpectWithOffset is part of the Ginkgo DSL
  102. var ExpectWithOffset = gomega.ExpectWithOffset
  103. // Eventually is part of the Ginkgo DSL
  104. var Eventually = gomega.Eventually
  105. // EventuallyWithOffset is part of the Ginkgo DSL
  106. var EventuallyWithOffset = gomega.EventuallyWithOffset
  107. // Consistently is part of the Ginkgo DSL
  108. var Consistently = gomega.Consistently
  109. // ConsistentlyWithOffset is part of the Ginkgo DSL
  110. var ConsistentlyWithOffset = gomega.ConsistentlyWithOffset
  111. // SetDefaultEventuallyTimeout is part of the Ginkgo DSL
  112. var SetDefaultEventuallyTimeout = gomega.SetDefaultEventuallyTimeout
  113. // SetDefaultEventuallyPollingInterval is part of the Ginkgo DSL
  114. var SetDefaultEventuallyPollingInterval = gomega.SetDefaultEventuallyPollingInterval
  115. // SetDefaultConsistentlyDuration is part of the Ginkgo DSL
  116. var SetDefaultConsistentlyDuration = gomega.SetDefaultConsistentlyDuration
  117. // SetDefaultConsistentlyPollingInterval is part of the Ginkgo DSL
  118. var SetDefaultConsistentlyPollingInterval = gomega.SetDefaultConsistentlyPollingInterval
  119. // Declarations for Gomega Matchers
  120. // Equal is part of the Ginkgo DSL
  121. var Equal = gomega.Equal
  122. // BeEquivalentTo is part of the Ginkgo DSL
  123. var BeEquivalentTo = gomega.BeEquivalentTo
  124. // BeIdenticalTo is part of the Ginkgo DSL
  125. var BeIdenticalTo = gomega.BeIdenticalTo
  126. // BeNil is part of the Ginkgo DSL
  127. var BeNil = gomega.BeNil
  128. // BeTrue is part of the Ginkgo DSL
  129. var BeTrue = gomega.BeTrue
  130. // BeFalse is part of the Ginkgo DSL
  131. var BeFalse = gomega.BeFalse
  132. // HaveOccurred is part of the Ginkgo DSL
  133. var HaveOccurred = gomega.HaveOccurred
  134. // Succeed is part of the Ginkgo DSL
  135. var Succeed = gomega.Succeed
  136. // MatchError is part of the Ginkgo DSL
  137. var MatchError = gomega.MatchError
  138. // BeClosed is part of the Ginkgo DSL
  139. var BeClosed = gomega.BeClosed
  140. // Receive is part of the Ginkgo DSL
  141. var Receive = gomega.Receive
  142. // BeSent is part of the Ginkgo DSL
  143. var BeSent = gomega.BeSent
  144. // MatchRegexp is part of the Ginkgo DSL
  145. var MatchRegexp = gomega.MatchRegexp
  146. // ContainSubstring is part of the Ginkgo DSL
  147. var ContainSubstring = gomega.ContainSubstring
  148. // HavePrefix is part of the Ginkgo DSL
  149. var HavePrefix = gomega.HavePrefix
  150. // HaveSuffix is part of the Ginkgo DSL
  151. var HaveSuffix = gomega.HaveSuffix
  152. // MatchJSON is part of the Ginkgo DSL
  153. var MatchJSON = gomega.MatchJSON
  154. // BeEmpty is part of the Ginkgo DSL
  155. var BeEmpty = gomega.BeEmpty
  156. // HaveLen is part of the Ginkgo DSL
  157. var HaveLen = gomega.HaveLen
  158. // HaveCap is part of the Ginkgo DSL
  159. var HaveCap = gomega.HaveCap
  160. // BeZero is part of the Ginkgo DSL
  161. var BeZero = gomega.BeZero
  162. // ContainElement is part of the Ginkgo DSL
  163. var ContainElement = gomega.ContainElement
  164. // ConsistOf is part of the Ginkgo DSL
  165. var ConsistOf = gomega.ConsistOf
  166. // HaveKey is part of the Ginkgo DSL
  167. var HaveKey = gomega.HaveKey
  168. // HaveKeyWithValue is part of the Ginkgo DSL
  169. var HaveKeyWithValue = gomega.HaveKeyWithValue
  170. // BeNumerically is part of the Ginkgo DSL
  171. var BeNumerically = gomega.BeNumerically
  172. // BeTemporally is part of the Ginkgo DSL
  173. var BeTemporally = gomega.BeTemporally
  174. // BeAssignableToTypeOf is part of the Ginkgo DSL
  175. var BeAssignableToTypeOf = gomega.BeAssignableToTypeOf
  176. // Panic is part of the Ginkgo DSL
  177. var Panic = gomega.Panic
  178. // BeAnExistingFile is part of the Ginkgo DSL
  179. var BeAnExistingFile = gomega.BeAnExistingFile
  180. // BeARegularFile is part of the Ginkgo DSL
  181. var BeARegularFile = gomega.BeARegularFile
  182. // BeADirectory is part of the Ginkgo DSL
  183. var BeADirectory = gomega.BeADirectory
  184. // And is part of the Ginkgo DSL
  185. var And = gomega.And
  186. // SatisfyAll is part of the Ginkgo DSL
  187. var SatisfyAll = gomega.SatisfyAll
  188. // Or is part of the Ginkgo DSL
  189. var Or = gomega.Or
  190. // SatisfyAny is part of the Ginkgo DSL
  191. var SatisfyAny = gomega.SatisfyAny
  192. // Not is part of the Ginkgo DSL
  193. var Not = gomega.Not
  194. // WithTransform is part of the Ginkgo DSL
  195. var WithTransform = gomega.WithTransform
  196. type pathMatcher struct {
  197. expected string
  198. }
  199. func (pm *pathMatcher) Match(actual interface{}) (bool, error) {
  200. szA, ok := actual.(string)
  201. if !ok {
  202. return false, errors.New("pathMatcher expects one or more strings")
  203. }
  204. return pm.expected == szA, nil
  205. }
  206. func (pm *pathMatcher) FailureMessage(actual interface{}) string {
  207. return fmt.Sprintf(
  208. "Expected\n\t%#v\nto be equal to\n\t%#v", actual, pm.expected)
  209. }
  210. func (pm *pathMatcher) NegatedFailureMessage(actual interface{}) string {
  211. return fmt.Sprintf(
  212. "Expected\n\t%#v\nnot to be equal to\n\t%#v", actual, pm.expected)
  213. }
  214. // Σ is a custom Ginkgo matcher.
  215. func Σ(paths ...string) gomegaTypes.GomegaMatcher {
  216. return &pathMatcher{path.Join(paths...)}
  217. }