mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2026-03-03 07:54:28 +01:00
rpcd has some bug that makes it crash when we do uci.revert. So reverts will always fail
This commit is contained in:
parent
556e87a266
commit
fa12aa2d55
2 changed files with 25 additions and 30 deletions
|
|
@ -405,10 +405,10 @@
|
|||
if(self[x].constructor == UCI.Section) to_delete[x] = self[x];
|
||||
});
|
||||
//console.log("To delete: "+Object.keys(to_delete));
|
||||
$rpc.uci.rollback({
|
||||
/*$rpc.uci.rollback({
|
||||
config: self[".name"],
|
||||
ubus_rpc_session: $rpc.$sid()
|
||||
}).done(function(){
|
||||
}).done(function(){*/
|
||||
$rpc.uci.state({
|
||||
config: self[".name"]
|
||||
}).done(function(data){
|
||||
|
|
@ -433,9 +433,9 @@
|
|||
}).fail(function(){
|
||||
deferred.reject();
|
||||
});
|
||||
}).fail(function(){
|
||||
/*}).fail(function(){
|
||||
deferred.reject("Could not revert config before sync!");
|
||||
});
|
||||
}); */
|
||||
return deferred.promise();
|
||||
}
|
||||
// set object values on objects that match search criteria
|
||||
|
|
|
|||
|
|
@ -4,7 +4,21 @@ require("./lib-juci");
|
|||
describe("UCI", function(){
|
||||
beforeEach(function(done){
|
||||
$uci.sync().done(function(){
|
||||
done();
|
||||
var to_delete = $uci.juci["@test"].map(function(x){
|
||||
return x;
|
||||
});
|
||||
// have to use a copy of the array because deletion modifies the array
|
||||
async.eachSeries(to_delete, function(section, next){
|
||||
section.$delete().done(function(){
|
||||
next();
|
||||
}).fail(function(){
|
||||
throw new Error("Was unable to delete section "+section[".name"]+" from config juci!");
|
||||
});
|
||||
}, function(){
|
||||
$uci.save().done(function(){
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
it("should have schema definition for each data field found in each defined uci config", function(done){
|
||||
|
|
@ -43,29 +57,6 @@ describe("UCI", function(){
|
|||
});
|
||||
//});
|
||||
});
|
||||
// deletes all sections that have type "test" from juci config and commits the changes
|
||||
it("should be able to delete unused test sections in juci config", function(done){ // this is just to get to a known state, but we can do it as a test :)
|
||||
$uci.sync("juci").done(function(){
|
||||
expect($uci.juci["@test"]).to.be.an(Array);
|
||||
var to_delete = $uci.juci["@test"].map(function(x){
|
||||
return x;
|
||||
});
|
||||
// have to use a copy of the array because deletion modifies the array
|
||||
async.eachSeries(to_delete, function(section, next){
|
||||
expect(section).to.be.ok();
|
||||
section.$delete().done(function(){
|
||||
next();
|
||||
}).fail(function(){
|
||||
throw new Error("Was unable to delete section "+section[".name"]+" from config juci!");
|
||||
});
|
||||
}, function(){
|
||||
expect($uci.juci["@test"]).to.be.empty();
|
||||
$uci.save().done(function(){
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
// will create an anonymous 'test' section and then delete it, commiting the changes
|
||||
it("should be able to add and delete an anonymous section", function(done){
|
||||
expect($uci.juci["@test"]).to.be.empty();
|
||||
|
|
@ -147,10 +138,14 @@ describe("UCI", function(){
|
|||
it("should not be able to add a section that already exists", function(done){
|
||||
expect($uci.juci["@test"]).to.be.empty();
|
||||
$uci.juci.create({".type": "test", ".name": "testname"}).done(function(section){
|
||||
$uci.juci.create({".type": "test", ".name": "testname"}).done(function(section){
|
||||
$uci.juci.create({".type": "test", ".name": "testname"}).done(function(section2){
|
||||
throw new Error("Creating a section that already exists returned success when it should fail!");
|
||||
}).fail(function(){
|
||||
done();
|
||||
section.$delete().done(function(){
|
||||
$uci.save().done(function(){
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
}).fail(function(){
|
||||
throw new Error("Failed to create section testname when it was supposed to work fine!");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue