Fix REST API monitor relationship test
The test did not properly move the relationships from the old monitor to the new one. The test to passed as the relationship modification was not really tested.
This commit is contained in:
@ -52,24 +52,26 @@ describe("Monitor Relationships", function() {
|
|||||||
relationships: {
|
relationships: {
|
||||||
servers: null
|
servers: null
|
||||||
}}}
|
}}}
|
||||||
return request.patch(base_url + "/monitors/MySQL-Monitor", {body: mon})
|
return request.patch(base_url + "/monitors/MySQL-Monitor", {json: mon})
|
||||||
.then(() => request.get(base_url + "/monitors/MySQL-Monitor", { json: true }))
|
.then(() => request.get(base_url + "/monitors/MySQL-Monitor", { json: true }))
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
res.data.relationships.servers.should.be.undefined
|
res.data.relationships.should.not.have.keys("servers")
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
it("add relationships to new monitor", function() {
|
it("add relationships to new monitor", function() {
|
||||||
var mon = { data: {
|
var mon = { data: {
|
||||||
relationships: {
|
relationships: {
|
||||||
servers: [
|
servers: {
|
||||||
|
data:[
|
||||||
{id: "server1", type: "servers"},
|
{id: "server1", type: "servers"},
|
||||||
{id: "server2", type: "servers"},
|
{id: "server2", type: "servers"},
|
||||||
{id: "server3", type: "servers"},
|
{id: "server3", type: "servers"},
|
||||||
{id: "server4", type: "servers"},
|
{id: "server4", type: "servers"},
|
||||||
]
|
]
|
||||||
|
}
|
||||||
}}}
|
}}}
|
||||||
return request.patch(base_url + "/monitors/" + monitor.data.id, {body: mon})
|
return request.patch(base_url + "/monitors/" + monitor.data.id, {json: mon})
|
||||||
.then(() => request.get(base_url + "/monitors/" + monitor.data.id, { json: true }))
|
.then(() => request.get(base_url + "/monitors/" + monitor.data.id, { json: true }))
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
res.data.relationships.servers.data.should.have.lengthOf(4)
|
res.data.relationships.servers.data.should.have.lengthOf(4)
|
||||||
@ -77,27 +79,26 @@ describe("Monitor Relationships", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("move relationships back to old monitor", function() {
|
it("move relationships back to old monitor", function() {
|
||||||
|
var mon = {data: {relationships: {servers: null}}}
|
||||||
return request.get(base_url + "/monitors/" + monitor.data.id)
|
|
||||||
.then(function(resp) {
|
|
||||||
var mon = JSON.parse(resp)
|
|
||||||
delete mon.data.relationships.servers
|
|
||||||
return request.patch(base_url + "/monitors/" + monitor.data.id, {json: mon})
|
return request.patch(base_url + "/monitors/" + monitor.data.id, {json: mon})
|
||||||
|
.then(() => request.get(base_url + "/monitors/" + monitor.data.id, { json: true }))
|
||||||
|
.then((res) => {
|
||||||
|
res.data.relationships.should.not.have.keys("servers")
|
||||||
})
|
})
|
||||||
.then(function() {
|
.then(function() {
|
||||||
return request.get(base_url + "/monitors/MySQL-Monitor")
|
mon.data.relationships.servers = {
|
||||||
})
|
data: [
|
||||||
.then(function(resp) {
|
|
||||||
var mon = JSON.parse(resp)
|
|
||||||
mon.data.relationships.servers = [
|
|
||||||
{id: "server1", type: "servers"},
|
{id: "server1", type: "servers"},
|
||||||
{id: "server2", type: "servers"},
|
{id: "server2", type: "servers"},
|
||||||
{id: "server3", type: "servers"},
|
{id: "server3", type: "servers"},
|
||||||
{id: "server4", type: "servers"},
|
{id: "server4", type: "servers"},
|
||||||
]
|
]}
|
||||||
return request.patch(base_url + "/monitors/MySQL-Monitor", {json: mon})
|
return request.patch(base_url + "/monitors/MySQL-Monitor", {json: mon})
|
||||||
})
|
})
|
||||||
.should.be.fulfilled
|
.then(() => request.get(base_url + "/monitors/MySQL-Monitor", { json: true }))
|
||||||
|
.then((res) => {
|
||||||
|
res.data.relationships.servers.data.should.have.lengthOf(4)
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
it("destroy created monitor", function() {
|
it("destroy created monitor", function() {
|
||||||
|
Reference in New Issue
Block a user