apiserv_test.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package apiserv_test
  2. import (
  3. "net/http"
  4. "testing"
  5. . "github.com/onsi/ginkgo"
  6. . "github.com/onsi/gomega"
  7. "github.com/vladimirok5959/golang-utils/utils/http/apiserv"
  8. )
  9. var _ = Describe("apiserv", func() {
  10. Context("Methods", func() {
  11. It("build correct array", func() {
  12. m := apiserv.Methods()
  13. Expect(m).To(Equal(apiserv.TMethods{}))
  14. // Single
  15. Expect(m.Delete()).To(Equal(apiserv.TMethods{http.MethodDelete}))
  16. Expect(m.Get()).To(Equal(apiserv.TMethods{http.MethodGet}))
  17. Expect(m.Options()).To(Equal(apiserv.TMethods{http.MethodOptions}))
  18. Expect(m.Patch()).To(Equal(apiserv.TMethods{http.MethodPatch}))
  19. Expect(m.Post()).To(Equal(apiserv.TMethods{http.MethodPost}))
  20. Expect(m.Put()).To(Equal(apiserv.TMethods{http.MethodPut}))
  21. // Multiple
  22. Expect(m.Get().Put()).To(Equal(apiserv.TMethods{
  23. http.MethodGet,
  24. http.MethodPut,
  25. }))
  26. Expect(m.Get().Post()).To(Equal(apiserv.TMethods{
  27. http.MethodGet,
  28. http.MethodPost,
  29. }))
  30. Expect(m.Get().Put().Post().Delete()).To(Equal(apiserv.TMethods{
  31. http.MethodGet,
  32. http.MethodPut,
  33. http.MethodPost,
  34. http.MethodDelete,
  35. }))
  36. })
  37. })
  38. })
  39. func TestSuite(t *testing.T) {
  40. RegisterFailHandler(Fail)
  41. RunSpecs(t, "apiserv")
  42. }