Fixed tests
This commit is contained in:
@@ -70,12 +70,14 @@ public class ContentPatcher{
|
|||||||
patches.clear();
|
patches.clear();
|
||||||
|
|
||||||
for(String patch : patchArray){
|
for(String patch : patchArray){
|
||||||
|
PatchSet set = new PatchSet(patch, new JsonValue("error"));
|
||||||
|
patches.add(set);
|
||||||
|
|
||||||
try{
|
try{
|
||||||
JsonValue value = parser.getJson().fromJson(null, Jval.read(patch).toString(Jformat.plain));
|
JsonValue value = parser.getJson().fromJson(null, Jval.read(patch).toString(Jformat.plain));
|
||||||
PatchSet set = new PatchSet(patch, value);
|
|
||||||
patches.add(set);
|
|
||||||
currentlyApplying = set;
|
currentlyApplying = set;
|
||||||
|
|
||||||
|
set.name = value.getString("name", "");
|
||||||
value.remove("name"); //patchsets can have a name, ignore it if present
|
value.remove("name"); //patchsets can have a name, ignore it if present
|
||||||
for(var child : value){
|
for(var child : value){
|
||||||
assign(root, child.name, child, null, null, null);
|
assign(root, child.name, child, null, null, null);
|
||||||
@@ -83,8 +85,9 @@ public class ContentPatcher{
|
|||||||
currentlyApplying = null;
|
currentlyApplying = null;
|
||||||
|
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
patches.peek().error = true;
|
set.error = true;
|
||||||
patches.peek().warnings.add(Strings.getSimpleMessage(e));
|
set.warnings.add(Strings.getSimpleMessage(e));
|
||||||
|
currentlyApplying = null;
|
||||||
|
|
||||||
Log.err("Failed to apply patch: " + patch, e);
|
Log.err("Failed to apply patch: " + patch, e);
|
||||||
}
|
}
|
||||||
@@ -516,14 +519,13 @@ public class ContentPatcher{
|
|||||||
public static class PatchSet{
|
public static class PatchSet{
|
||||||
public String patch;
|
public String patch;
|
||||||
public JsonValue json;
|
public JsonValue json;
|
||||||
public String name;
|
public String name = "";
|
||||||
public boolean error;
|
public boolean error;
|
||||||
public Seq<String> warnings = new Seq<>();
|
public Seq<String> warnings = new Seq<>();
|
||||||
|
|
||||||
public PatchSet(String patch, JsonValue json){
|
public PatchSet(String patch, JsonValue json){
|
||||||
this.patch = patch;
|
this.patch = patch;
|
||||||
this.json = json;
|
this.json = json;
|
||||||
name = json.getString("name", "");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -244,7 +244,7 @@ public class PatcherTests{
|
|||||||
unit.dagger.frogs: 10
|
unit.dagger.frogs: 10
|
||||||
"""));
|
"""));
|
||||||
|
|
||||||
assertEquals(1, Vars.state.patcher.patches.first().warnings.size);
|
assertEquals(2, Vars.state.patcher.patches.first().warnings.size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user