Skip to content

Commit

Permalink
Merge pull request #17 from plombard/ADD_HEAD_METHOD
Browse files Browse the repository at this point in the history
- Add head http method.
  • Loading branch information
ducaale authored Feb 7, 2021
2 parents 6dd3797 + 84d9d49 commit 4c11c6e
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 2 deletions.
23 changes: 21 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ features = ["parsing", "html", "yaml-load", "dump-load", "dump-create", "regex-o
[dev-dependencies]
assert_cmd = "1.0"
indoc = "1.0"
predicates = "1.0.7"

[build-dependencies]
syntect = { version = "4.4", default-features = false }
3 changes: 3 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ pub enum Method {
PUT,
PATCH,
DELETE,
OPTIONS,
}

impl FromStr for Method {
Expand All @@ -138,6 +139,7 @@ impl FromStr for Method {
"PUT" => Ok(Method::PUT),
"PATCH" => Ok(Method::PATCH),
"DELETE" => Ok(Method::DELETE),
"OPTIONS" => Ok(Method::OPTIONS),
method => {
return Err(Error::with_description(
&format!("unknown http method {}", method),
Expand All @@ -157,6 +159,7 @@ impl From<Method> for reqwest::Method {
Method::PUT => reqwest::Method::PUT,
Method::PATCH => reqwest::Method::PATCH,
Method::DELETE => reqwest::Method::DELETE,
Method::OPTIONS => reqwest::Method::OPTIONS,
}
}
}
Expand Down
17 changes: 17 additions & 0 deletions tests/cli.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use assert_cmd::prelude::*;
use indoc::indoc;
use std::process::Command;
use predicates::prelude::*;

#[test]
fn basic_post() -> Result<(), Box<dyn std::error::Error>> {
Expand Down Expand Up @@ -74,3 +75,19 @@ fn basic_head() -> Result<(), Box<dyn std::error::Error>> {

Ok(())
}

#[test]
fn basic_options() -> Result<(), Box<dyn std::error::Error>> {
let mut cmd = Command::cargo_bin("ht")?;
cmd.arg("-v")
.arg("--ignore-stdin")
.arg("--pretty=format")
.arg("options")
.arg("httpbin.org/json");

// Verify that the response is ok and contains an 'allow' header.
cmd.assert().stdout(predicate::str::contains("HTTP/1.1 200 OK"));
cmd.assert().stdout(predicate::str::contains("allow:"));

Ok(())
}

0 comments on commit 4c11c6e

Please sign in to comment.