mirror of
https://github.com/aclindsa/moneygo.git
synced 2024-12-26 23:42:29 -05:00
Add a test for limiting security templates returned
This commit is contained in:
parent
e239d62034
commit
a6e2b33dd0
@ -50,18 +50,21 @@ func TestSecurityTemplates(t *testing.T) {
|
|||||||
var sl handlers.SecurityList
|
var sl handlers.SecurityList
|
||||||
response, err := http.Get(server.URL + "/securitytemplate/?search=USD&type=currency")
|
response, err := http.Get(server.URL + "/securitytemplate/?search=USD&type=currency")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if response.StatusCode != 200 {
|
||||||
|
t.Fatalf("Unexpected HTTP status code: %d\n", response.StatusCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(response.Body)
|
body, err := ioutil.ReadAll(response.Body)
|
||||||
response.Body.Close()
|
response.Body.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = (&sl).Read(string(body))
|
err = (&sl).Read(string(body))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
num_usd := 0
|
num_usd := 0
|
||||||
@ -79,3 +82,29 @@ func TestSecurityTemplates(t *testing.T) {
|
|||||||
t.Fatalf("Expected one USD security template, found %d\n", num_usd)
|
t.Fatalf("Expected one USD security template, found %d\n", num_usd)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSecurityTemplateLimit(t *testing.T) {
|
||||||
|
var sl handlers.SecurityList
|
||||||
|
response, err := http.Get(server.URL + "/securitytemplate/?search=e&limit=5")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if response.StatusCode != 200 {
|
||||||
|
t.Fatalf("Unexpected HTTP status code: %d\n", response.StatusCode)
|
||||||
|
}
|
||||||
|
|
||||||
|
body, err := ioutil.ReadAll(response.Body)
|
||||||
|
response.Body.Close()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = (&sl).Read(string(body))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(*sl.Securities) > 5 {
|
||||||
|
t.Fatalf("Requested only 5 securities, received %d\n", len(*sl.Securities))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user