Skip to content

Commit

Permalink
Merge pull request #118 from jordanbcooper/master
Browse files Browse the repository at this point in the history
Added PagedListQueuesWithParameters endpoint + Tests
  • Loading branch information
michaelklishin authored Oct 19, 2018
2 parents 54e00ef + 1835313 commit 7fa9b8b
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
24 changes: 24 additions & 0 deletions queues.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@ type QueueInfo struct {
ActiveConsumers int64 `json:"active_consumers"`
}

type PagedQueueInfo struct {
Page int `json:"page"`
PageCount int `json:"page_count"`
PageSize int `json:"page_size"`
FilteredCount int `json:"filtered_count"`
ItemCount int `json:"item_count"`
TotalCount int `json:"total_count"`
Items []QueueInfo `json:"items"`
}

type DetailedQueueInfo QueueInfo

//
Expand Down Expand Up @@ -195,6 +205,20 @@ func (c *Client) ListQueuesWithParameters(params url.Values) (rec []QueueInfo, e
return rec, nil
}

func (c *Client) PagedListQueuesWithParameters(params url.Values) (rec PagedQueueInfo, err error) {
req, err := newGETRequestWithParameters(c, "queues", params)
if err != nil {
return PagedQueueInfo{}, err
}

if err = executeAndParseRequest(c, req, &rec); err != nil {
return PagedQueueInfo{}, err
}

return rec, nil

}

//
// GET /api/queues/{vhost}
//
Expand Down
42 changes: 42 additions & 0 deletions rabbithole_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,48 @@ var _ = Describe("Rabbithole", func() {
})
})

Context("GET /queues paged with arguments", func() {
It("returns decoded response", func() {
conn := openConnection("/")
defer conn.Close()

ch, err := conn.Channel()
Ω(err).Should(BeNil())
defer ch.Close()

_, err = ch.QueueDeclare(
"", // name
false, // durable
false, // auto delete
true, // exclusive
false,
nil)
Ω(err).Should(BeNil())

// give internal events a moment to be
// handled
awaitEventPropagation()

params := url.Values{}
params.Add("page", "1")

qs, err := rmqc.PagedListQueuesWithParameters(params)
Ω(err).Should(BeNil())

q := qs.Items[0]
Ω(q.Name).ShouldNot(Equal(""))
Ω(q.Node).ShouldNot(BeNil())
Ω(q.Durable).ShouldNot(BeNil())
Ω(q.Status).ShouldNot(BeNil())
Ω(qs.Page).Should(Equal(1))
Ω(qs.PageCount).Should(Equal(1))
Ω(qs.ItemCount).ShouldNot(BeNil())
Ω(qs.PageSize).Should(Equal(100))
Ω(qs.TotalCount).ShouldNot(BeNil())
Ω(qs.FilteredCount).ShouldNot(BeNil())
})
})

Context("GET /queues/{vhost}", func() {
It("returns decoded response", func() {
conn := openConnection("rabbit/hole")
Expand Down

0 comments on commit 7fa9b8b

Please sign in to comment.