Skip to content

Commit

Permalink
Add more tests for error cases
Browse files Browse the repository at this point in the history
  • Loading branch information
ascandella committed Jun 28, 2015
1 parent 8aa053c commit 25c5704
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package com.uber.jenkins.phabricator.conduit;

import hudson.Launcher;
import net.sf.json.JSONException;
import net.sf.json.JSONObject;
import org.junit.Rule;
import org.junit.Test;
Expand Down Expand Up @@ -64,6 +65,19 @@ public void testParseConduit() throws Exception {
assertEquals(result.getString("hello"), "world");
}

@Test(expected = ArcanistUsageException.class)
public void testNonZeroExitCode() throws Exception {
ArcanistClient client = new ArcanistClient("false", "", emptyParams, null);

client.parseConduit(getLauncher().launch(), System.err);
}

@Test(expected = JSONException.class)
public void testNonJsonOutput() throws Exception {
ArcanistClient client = new ArcanistClient("echo", "not-json", emptyParams, null);
client.parseConduit(getLauncher().launch(), System.err);
}

private Launcher getLauncher() {
return j.createLocalLauncher();
}
Expand Down

0 comments on commit 25c5704

Please sign in to comment.