Update REST API tests
Extended the relationship checks in the REST API tests to actually verify that the returned objects represent what is expected.
This commit is contained in:
parent
582a65f77c
commit
b7b50959ac
@ -48,30 +48,32 @@ describe("Monitor Relationships", function() {
|
||||
})
|
||||
|
||||
it("remove relationships from old monitor", function() {
|
||||
|
||||
return request.get(base_url + "/monitors/MySQL-Monitor")
|
||||
.then(function(resp) {
|
||||
var mon = JSON.parse(resp)
|
||||
delete mon.data.relationships.servers
|
||||
return request.patch(base_url + "/monitors/MySQL-Monitor", {json: mon})
|
||||
})
|
||||
.should.be.fulfilled
|
||||
var mon = { data: {
|
||||
relationships: {
|
||||
servers: null
|
||||
}}}
|
||||
return request.patch(base_url + "/monitors/MySQL-Monitor", {body: mon})
|
||||
.then(() => request.get(base_url + "/monitors/MySQL-Monitor", { json: true }))
|
||||
.then((res) => {
|
||||
res.data.relationships.servers.should.be.undefined
|
||||
})
|
||||
});
|
||||
|
||||
it("add relationships to new monitor", function() {
|
||||
|
||||
return request.get(base_url + "/monitors/" + monitor.data.id)
|
||||
.then(function(resp) {
|
||||
var mon = JSON.parse(resp)
|
||||
mon.data.relationships.servers = [
|
||||
var mon = { data: {
|
||||
relationships: {
|
||||
servers: [
|
||||
{id: "server1", type: "servers"},
|
||||
{id: "server2", type: "servers"},
|
||||
{id: "server3", type: "servers"},
|
||||
{id: "server4", type: "servers"},
|
||||
]
|
||||
return request.patch(base_url + "/monitors/" + monitor.data.id, {json: mon})
|
||||
}}}
|
||||
return request.patch(base_url + "/monitors/" + monitor.data.id, {body: mon})
|
||||
.then(() => request.get(base_url + "/monitors/" + monitor.data.id, { json: true }))
|
||||
.then((res) => {
|
||||
res.data.relationships.servers.data.should.have.lengthOf(4)
|
||||
})
|
||||
.should.be.fulfilled
|
||||
});
|
||||
|
||||
it("move relationships back to old monitor", function() {
|
||||
|
@ -57,14 +57,16 @@ describe("Server Relationships", function() {
|
||||
var rel_server = JSON.parse(JSON.stringify(server))
|
||||
rel_server.data.relationships = rel
|
||||
|
||||
it("create new server", function() {
|
||||
it("create new server with relationships", function() {
|
||||
return request.post(base_url + "/servers/", {json: rel_server})
|
||||
.should.be.fulfilled
|
||||
});
|
||||
|
||||
it("request server", function() {
|
||||
return request.get(base_url + "/servers/" + rel_server.data.id)
|
||||
.should.be.fulfilled
|
||||
return request.get(base_url + "/servers/" + rel_server.data.id, { json: true })
|
||||
.then((res) => {
|
||||
res.data.relationships.services.data.should.have.lengthOf(2)
|
||||
})
|
||||
});
|
||||
|
||||
it("remove relationships", function() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user