Fork of daniellemaywood.uk/gleam — Wasm codegen work
2

Configure Feed

Select the types of activity you want to include in your feed.

Handle case where path field is empty

+22
+13
compiler-core/src/requirement.rs
··· 176 176 path: Some(path), .. 177 177 } = &requirement 178 178 { 179 + if path.as_str().is_empty() { 180 + return Err(de::Error::custom("git dependency path must not be empty")); 181 + } 179 182 crate::io::validate_safe_relative_path(path).map_err(de::Error::custom)?; 180 183 } 181 184 Ok(requirement) ··· 225 228 226 229 let error = 227 230 toml::from_str::<HashMap<String, Requirement>>(toml).expect_err("escaping path"); 231 + insta::assert_snapshot!(error.to_string()); 232 + } 233 + 234 + #[test] 235 + fn read_git_requirement_with_empty_path() { 236 + let toml = r#" 237 + monorepo = { git = "https://github.com/gleam-lang/gleam.git", ref = "main", path = "" } 238 + "#; 239 + 240 + let error = toml::from_str::<HashMap<String, Requirement>>(toml).expect_err("empty path"); 228 241 insta::assert_snapshot!(error.to_string()); 229 242 } 230 243 }
+9
compiler-core/src/snapshots/gleam_core__requirement__tests__read_git_requirement_with_empty_path.snap
··· 1 + --- 2 + source: compiler-core/src/requirement.rs 3 + expression: error.to_string() 4 + --- 5 + TOML parse error at line 2, column 24 6 + | 7 + 2 | monorepo = { git = "https://github.com/gleam-lang/gleam.git", ref = "main", path = "" } 8 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 9 + git dependency path must not be empty