|
6 | 6 |
|
7 | 7 | "github.com/stretchr/testify/mock"
|
8 | 8 |
|
| 9 | + "github.com/hieven/go-instagram/src/constants" |
9 | 10 | "github.com/hieven/go-instagram/src/protos"
|
10 | 11 | requestMocks "github.com/hieven/go-instagram/src/utils/request/mocks"
|
11 | 12 | . "github.com/onsi/ginkgo"
|
@@ -63,6 +64,46 @@ var _ = Describe("inbox", func() {
|
63 | 64 | Expect(err).To(BeNil())
|
64 | 65 | Expect(resp).NotTo(BeNil())
|
65 | 66 | })
|
| 67 | + |
| 68 | + It("should call Get", func() { |
| 69 | + mockRequestManager.AssertNumberOfCalls(GinkgoT(), "Get", 1) |
| 70 | + mockRequestManager.AssertCalled(GinkgoT(), "Get", mock.Anything, constants.InboxEndpoint) |
| 71 | + }) |
| 72 | + }) |
| 73 | + |
| 74 | + Context("when cursor is provded", func() { |
| 75 | + BeforeEach(func() { |
| 76 | + req.Cursor = "cursor" |
| 77 | + }) |
| 78 | + |
| 79 | + It("should set query string", func() { |
| 80 | + mockRequestManager.AssertCalled(GinkgoT(), "Get", mock.Anything, constants.InboxEndpoint+"?cursor="+req.Cursor) |
| 81 | + }) |
66 | 82 | })
|
| 83 | + |
| 84 | + tests := []struct { |
| 85 | + desc string |
| 86 | + beforeFunc func() |
| 87 | + expectedErr error |
| 88 | + }{ |
| 89 | + { |
| 90 | + desc: "when req is missing", |
| 91 | + beforeFunc: func() { req = nil }, |
| 92 | + expectedErr: ErrRequestRequired, |
| 93 | + }, |
| 94 | + } |
| 95 | + |
| 96 | + for _, test := range tests { |
| 97 | + t := test |
| 98 | + Context(t.desc, func() { |
| 99 | + BeforeEach(t.beforeFunc) |
| 100 | + |
| 101 | + It("should return error", func() { |
| 102 | + Expect(resp).To(BeNil()) |
| 103 | + Expect(err).NotTo(BeNil()) |
| 104 | + Expect(err).To(Equal(t.expectedErr)) |
| 105 | + }) |
| 106 | + }) |
| 107 | + } |
67 | 108 | })
|
68 | 109 | })
|
0 commit comments