Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added PagedListQueuesWithParameters endpoint + Tests #118

Merged
merged 5 commits into from
Oct 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions queues.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,16 @@ type QueueInfo struct {
BackingQueueStatus BackingQueueStatus `json:"backing_queue_status"`
}

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 @@ -193,6 +203,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