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:
parent
b7b50959ac
commit
7111724851
@ -52,24 +52,26 @@ describe("Monitor Relationships", function() {
|
||||
relationships: {
|
||||
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((res) => {
|
||||
res.data.relationships.servers.should.be.undefined
|
||||
res.data.relationships.should.not.have.keys("servers")
|
||||
})
|
||||
});
|
||||
|
||||
it("add relationships to new monitor", function() {
|
||||
var mon = { data: {
|
||||
relationships: {
|
||||
servers: [
|
||||
{id: "server1", type: "servers"},
|
||||
{id: "server2", type: "servers"},
|
||||
{id: "server3", type: "servers"},
|
||||
{id: "server4", type: "servers"},
|
||||
]
|
||||
servers: {
|
||||
data:[
|
||||
{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, {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((res) => {
|
||||
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() {
|
||||
|
||||
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})
|
||||
var mon = {data: {relationships: {servers: null}}}
|
||||
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() {
|
||||
return request.get(base_url + "/monitors/MySQL-Monitor")
|
||||
})
|
||||
.then(function(resp) {
|
||||
var mon = JSON.parse(resp)
|
||||
mon.data.relationships.servers = [
|
||||
{id: "server1", type: "servers"},
|
||||
{id: "server2", type: "servers"},
|
||||
{id: "server3", type: "servers"},
|
||||
{id: "server4", type: "servers"},
|
||||
]
|
||||
mon.data.relationships.servers = {
|
||||
data: [
|
||||
{id: "server1", type: "servers"},
|
||||
{id: "server2", type: "servers"},
|
||||
{id: "server3", type: "servers"},
|
||||
{id: "server4", type: "servers"},
|
||||
]}
|
||||
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() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user