Repository: algesten/ureq
Pull request #239 (2020-11-22 08:14:35)

Remove "what" section of test matrix.
We were generating two whole sets of jobs, for --tests and --docs
separately. But the default invocation of cargo runs both tests and
doctests. We can save some resources and speed up our test runs by
allowing cargo to do both in one invocation.


Patch:
diff --git a/src/header.rs b/src/header.rs
index 5fb5675..038a0b0 100644
--- a/src/header.rs
+++ b/src/header.rs
@@ -29,37 +29,16 @@ impl Header {
     }
 
     /// The header name.
-    ///
-    /// ```
-    /// let header = "X-Forwarded-For: 127.0.0.1"
-    ///     .parse::<ureq::Header>()
-    ///     .unwrap();
-    /// assert_eq!("X-Forwarded-For", header.name());
-    /// ```
     pub fn name(&self) -> &str {
         &self.line.as_str()[0..self.index]
     }
 
     /// The header value.
-    ///
-    /// ```
-    /// let header = "X-Forwarded-For: 127.0.0.1"
-    ///     .parse::<ureq::Header>()
-    ///     .unwrap();
-    /// assert_eq!("127.0.0.1", header.value());
-    /// ```
     pub fn value(&self) -> &str {
         &self.line.as_str()[self.index + 1..].trim()
     }
 
     /// Compares the given str to the header name ignoring case.
-    ///
-    /// ```
-    /// let header = "X-Forwarded-For: 127.0.0.1"
-    ///     .parse::<ureq::Header>()
-    ///     .unwrap();
-    /// assert!(header.is_name("x-forwarded-for"));
-    /// ```
     pub fn is_name(&self, other: &str) -> bool {
         self.name().eq_ignore_ascii_case(other)
     }
@@ -225,3 +204,13 @@ fn value_with_whitespace() {
     let h = "foo:      bar    ".parse::<Header>().unwrap();
     assert_eq!(h.value(), "bar");
 }
+
+#[test]
+fn name_and_value() {
+    let header: Header = "X-Forwarded-For: 127.0.0.1".parse().unwrap();
+    assert_eq!("X-Forwarded-For", header.name());
+    assert_eq!("127.0.0.1", header.value());
+    assert!(header.is_name("X-Forwarded-For"));
+    assert!(header.is_name("x-forwarded-for"));
+    assert!(header.is_name("X-FORWARDED-FOR"));
+}
diff --git a/src/unit.rs b/src/unit.rs
index 51784d6..166fc12 100644
--- a/src/unit.rs
+++ b/src/unit.rs
@@ -7,16 +7,14 @@ use url::Url;
 #[cfg(feature = "cookies")]
 use cookie::Cookie;
 
+use crate::body::{self, BodySize, Payload, SizedReader};
 use crate::error::{Error, ErrorKind};
 use crate::header;
+use crate::header::{get_header, Header};
 use crate::resolve::ArcResolver;
+use crate::response::Response;
 use crate::stream::{self, connect_test, Stream};
 use crate::Agent;
-use crate::{
-    body::{self, BodySize, Payload, SizedReader},
-    header::get_header,
-};
-use crate::{Header, Response};
 
 /// A Unit is fully-built Request, ready to execute.
 ///


Test patch:
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 90a02f4..91f988d 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -33,9 +33,6 @@ jobs:
           - charset
           - cookies
           - socks-proxy
-        what:
-          - "--doc"
-          - "--tests"
     env:
       RUST_BACKTRACE: "1"
       RUSTFLAGS: "-D dead_code -D unused-variables -D unused"
@@ -50,4 +47,4 @@ jobs:
         uses: actions-rs/cargo@v1
         with:
           command: test
-          args: ${{ matrix.what }} --no-default-features --features "${{ matrix.tls }} ${{ matrix.feature }}"
+          args: --no-default-features --features "${{ matrix.tls }} ${{ matrix.feature }}"
diff --git a/test.sh b/test.sh
index ed7db80..274c2fd 100755
--- a/test.sh
+++ b/test.sh
@@ -6,11 +6,9 @@ export RUSTFLAGS="-D dead_code -D unused-variables -D unused"
 
 for tls in "" tls ; do
   for feature in "" json charset cookies socks-proxy ; do
-    for what in --doc --tests ; do
-      if ! cargo test "${what}" --no-default-features --features "${tls} ${feature}" ; then
-        echo Command failed: cargo test \"${what}\" --no-default-features --features \"${tls} ${feature}\"
-        exit 1
-      fi
-    done
+    if ! cargo test --no-default-features --features "${tls} ${feature}" ; then
+      echo Command failed: cargo test \"${what}\" --no-default-features --features \"${tls} ${feature}\"
+      exit 1
+    fi
   done
 done