Repository: peterheesterman/chit (language: rust)

Issue:
Tests require network access
**Describe the bug**
The `chit::details::alternatives::tests::can_parse_alternatives` test fails when run in a sandboxed environment because it requires network access. Unit tests shouldn't use network access.

```
  thread 'main' panicked at 'Alternative retrieval failed: ConnectionError(Error { kind: Hyper(Error { kind: Connect, cause: Custom { kind: Other, error: StringError("failed to lookup address information: Name or service not known") } }), url: Some("https://raw.githubusercontent.com/peterheesterman/chit/master/alternatives.json") })', src/libcore/result.rs:997:5
  note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
  
  
  failures:
      chit::details::alternatives::tests::can_parse_alternatives
  
  test result: FAILED. 12 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out
```

**To Reproduce**
Run the unit tests in a sandbox that disallows network access.

**Expected behavior**
The unit tests should not rely on network access.

**Desktop (please complete the following information):**
Tested in NixOS



Discussion / hints:

Fix patch:
diff --git a/.gitignore b/.gitignore
index 1de5659..5bd05d6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,1 +1,2 @@
-target
\ No newline at end of file
+target
+.idea
\ No newline at end of file
diff --git a/src/chit/details/alternatives/mod.rs b/src/chit/details/alternatives/mod.rs
index 6922a23..eed03b9 100644
--- a/src/chit/details/alternatives/mod.rs
+++ b/src/chit/details/alternatives/mod.rs
@@ -90,9 +90,12 @@ pub fn get_alternatives() -> Result<Alternatives, RetrieveAlternativesError> {
 mod tests {
     use super::*;
 
+    const ALTERNATIVES_JSON: &str = include_str!("../../../../alternatives.json");
+    /// Tests if the alternatives.json file in the root of this crate can be parsed.
     #[test]
     fn can_parse_alternatives() {
-        let alternatives = get_alternatives().expect("Alternative retrieval failed");
+        let alternatives: Alternatives =
+            serde_json::from_str(&ALTERNATIVES_JSON).expect("Alternative parsing failed");
         assert_ne!(alternatives.sets.len(), 0)
     }
 }
diff --git a/src/chit/details/mod.rs b/src/chit/details/mod.rs
index 0002d6e..e224fe0 100644
--- a/src/chit/details/mod.rs
+++ b/src/chit/details/mod.rs
@@ -72,7 +72,7 @@ pub fn print_details(crate_name: String) {
                     ));
                 }
 
-                // IDEA: Clean this up by making it less imparative and into another file
+                // IDEA: Clean this up by making it less imperative and into another file
                 let mut found_alternative = false;
                 let alternatives = alternatives::get_alternatives();
 


Test patch: