Skip to content

Commit

Permalink
update most tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfv committed Dec 17, 2024
1 parent 9333991 commit 16aaaf7
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 50 deletions.
10 changes: 5 additions & 5 deletions crates/rattler_conda_types/src/match_spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -702,12 +702,12 @@ mod tests {

#[test]
fn test_serialize_matchspec() {
let specs = ["mamba 1.0 py37_0",
"conda-forge::pytest[version=1.0, sha256=aaac4bc9c6916ecc0e33137431645b029ade22190c7144eead61446dcbcc6f97, md5=dede6252c964db3f3e41c7d30d07f6bf]",
let specs = ["mamba 1.0.* py37_0",
"conda-forge::pytest[version='==1.0', sha256=aaac4bc9c6916ecc0e33137431645b029ade22190c7144eead61446dcbcc6f97, md5=dede6252c964db3f3e41c7d30d07f6bf]",
"conda-forge/linux-64::pytest",
"conda-forge/linux-64::pytest[version=1.0]",
"conda-forge/linux-64::pytest[version=1.0, build=py37_0]",
"conda-forge/linux-64::pytest 1.2.3"];
"conda-forge/linux-64::pytest[version=1.0.*]",
"conda-forge/linux-64::pytest[version=1.0.*, build=py37_0]",
"conda-forge/linux-64::pytest ==1.2.3"];

assert_snapshot!(specs
.into_iter()
Expand Down
2 changes: 1 addition & 1 deletion crates/rattler_conda_types/src/match_spec/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ mod tests {
fn test_nameless_match_spec() {
insta::assert_yaml_snapshot!([
NamelessMatchSpec::from_str("3.8.* *_cpython", Strict).unwrap(),
NamelessMatchSpec::from_str("1.0 py27_0[fn=\"bla\"]", Strict).unwrap(),
NamelessMatchSpec::from_str("1.0.* py27_0[fn=\"bla\"]", Strict).unwrap(),
NamelessMatchSpec::from_str("=1.0 py27_0", Strict).unwrap(),
NamelessMatchSpec::from_str("*cpu*", Strict).unwrap(),
NamelessMatchSpec::from_str("conda-forge::foobar", Strict).unwrap(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,32 +54,13 @@ python=3.9:
python=*:
error: "invalid version constraint: '*' is incompatible with '=' operator'"
"https://software.repos.intel.com/python/conda::python[version=3.9]":
name: python
version: "==3.9"
channel:
base_url: "https://software.repos.intel.com/python/conda"
name: python/conda
error: "invalid version constraint: ambiguous. Do you mean ==3.9 or 3.9.*?"
"https://c.com/p/conda/linux-64::python[version=3.9]":
name: python
version: "==3.9"
channel:
base_url: "https://c.com/p/conda"
name: p/conda
subdir: linux-64
error: "invalid version constraint: ambiguous. Do you mean ==3.9 or 3.9.*?"
"https://c.com/p/conda::python[version=3.9, subdir=linux-64]":
name: python
version: "==3.9"
channel:
base_url: "https://c.com/p/conda"
name: p/conda
subdir: linux-64
error: "invalid version constraint: ambiguous. Do you mean ==3.9 or 3.9.*?"
"conda-forge/linux-32::python[version=3.9, subdir=linux-64]":
name: python
version: "==3.9"
channel:
base_url: "https://conda.anaconda.org/conda-forge"
name: conda-forge
subdir: linux-64
error: "invalid version constraint: ambiguous. Do you mean ==3.9 or 3.9.*?"
"conda-forge/linux-32::python ==3.9[subdir=linux-64, build_number=\"0\"]":
name: python
version: "==3.9"
Expand Down Expand Up @@ -119,11 +100,7 @@ rust ~=1.2.3:
base_url: "file://<CRATE>/relative/channel"
name: "./relative/channel"
"python[channel=https://conda.anaconda.org/python/conda,version=3.9]":
name: python
version: "==3.9"
channel:
base_url: "https://conda.anaconda.org/python/conda"
name: python/conda
error: "invalid version constraint: ambiguous. Do you mean ==3.9 or 3.9.*?"
"channel/win-64::foobar[channel=conda-forge, subdir=linux-64]":
name: foobar
channel:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ source: crates/rattler_conda_types/src/match_spec/parse.rs
expression: evaluated
---
2.7|>=3.6:
version: "==2.7|>=3.6"
error: "invalid version constraint: ambiguous. Do you mean ==2.7 or 2.7.*?"
"https://conda.anaconda.org/conda-forge/linux-64/_libgcc_mutex-0.1-conda_forge.tar.bz2":
url: "https://conda.anaconda.org/conda-forge/linux-64/_libgcc_mutex-0.1-conda_forge.tar.bz2"
~=1.2.3:
Expand Down Expand Up @@ -40,14 +40,13 @@ expression: evaluated
"==2.7.*.*|>=3.6":
error: "invalid version constraint: regex constraints are not supported"
"3.9":
version: "==3.9"
error: "invalid version constraint: ambiguous. Do you mean ==3.9 or 3.9.*?"
"*":
version: "*"
"[version=3.9]":
version: "==3.9"
error: "invalid version constraint: ambiguous. Do you mean ==3.9 or 3.9.*?"
"[version=3.9, subdir=linux-64]":
version: "==3.9"
subdir: linux-64
error: "invalid version constraint: ambiguous. Do you mean ==3.9 or 3.9.*?"
"==3.9[subdir=linux-64, build_number=\"0\"]":
version: "==3.9"
build_number:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
source: crates/rattler_conda_types/src/match_spec/mod.rs
expression: "specs.into_iter().map(|s|\nMatchSpec::from_str(s,\nStrict).unwrap()).map(|s| s.to_string()).collect::<Vec<String>>().join(\"\\n\")"
---
mamba ==1.0 py37_0
mamba 1.0.* py37_0
conda-forge::pytest ==1.0[md5="dede6252c964db3f3e41c7d30d07f6bf", sha256="aaac4bc9c6916ecc0e33137431645b029ade22190c7144eead61446dcbcc6f97"]
conda-forge/linux-64::pytest
conda-forge/linux-64::pytest ==1.0
conda-forge/linux-64::pytest ==1.0 py37_0
conda-forge/linux-64::pytest 1.0.*
conda-forge/linux-64::pytest 1.0.* py37_0
conda-forge/linux-64::pytest ==1.2.3
2 changes: 1 addition & 1 deletion crates/rattler_conda_types/src/version_spec/constraint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ mod test {
#[rstest]
fn test_exact(#[values(Lenient, Strict)] strictness: ParseStrictness) {
assert_eq!(
Constraint::from_str("1.2.3", strictness),
Constraint::from_str("==1.2.3", strictness),
Ok(Constraint::Exact(
EqualityOperator::Equals,
Version::from_str("1.2.3").unwrap(),
Expand Down
17 changes: 12 additions & 5 deletions crates/rattler_conda_types/src/version_spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,15 +350,15 @@ mod tests {
use crate::{
version_spec::{
parse::ParseConstraintError, EqualityOperator, LogicalOperator, ParseVersionSpecError,
RangeOperator,
RangeOperator, StrictRangeOperator,
},
ParseStrictness, Version, VersionSpec,
ParseStrictness, StrictVersion, Version, VersionSpec,
};

#[test]
fn test_simple() {
assert_eq!(
VersionSpec::from_str("1.2.3", ParseStrictness::Strict),
VersionSpec::from_str("==1.2.3", ParseStrictness::Strict),
Ok(VersionSpec::Exact(
EqualityOperator::Equals,
Version::from_str("1.2.3").unwrap(),
Expand All @@ -371,6 +371,13 @@ mod tests {
Version::from_str("1.2.3").unwrap(),
))
);
assert_eq!(
VersionSpec::from_str("=1.2.3", ParseStrictness::Strict),
Ok(VersionSpec::StrictRange(
StrictRangeOperator::StartsWith,
StrictVersion::from_str("1.2.3").unwrap(),
))
);
}

#[test]
Expand Down Expand Up @@ -422,14 +429,14 @@ mod tests {
let vs1 = VersionSpec::from_str(">=1.2.3,<2.0.0", ParseStrictness::Strict).unwrap();
assert!(!vs1.matches(&v1));

let vs2 = VersionSpec::from_str("1.2", ParseStrictness::Strict).unwrap();
let vs2 = VersionSpec::from_str("==1.2.0", ParseStrictness::Strict).unwrap();
assert!(vs2.matches(&v1));

let v2 = Version::from_str("1.2.3").unwrap();
assert!(vs1.matches(&v2));
assert!(!vs2.matches(&v2));

let v3 = Version::from_str("1!1.2.3").unwrap();
let v3 = Version::from_str("1!1.2.3.*").unwrap();
println!("{v3:?}");

assert!(!vs1.matches(&v3));
Expand Down
4 changes: 2 additions & 2 deletions crates/rattler_conda_types/src/version_spec/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ mod test {
#[rstest]
fn parse_logical_constraint(#[values(Lenient, Strict)] strictness: ParseStrictness) {
assert_eq!(
logical_constraint_parser(strictness)("3.1"),
logical_constraint_parser(strictness)("==3.1"),
Ok((
"",
Constraint::Exact(EqualityOperator::Equals, Version::from_str("3.1").unwrap())
Expand Down Expand Up @@ -520,7 +520,7 @@ mod test {

#[test]
fn pixi_issue_278() {
assert!(VersionSpec::from_str("1.8.1+g6b29558", Strict).is_ok());
assert!(VersionSpec::from_str("=1.8.1+g6b29558", Strict).is_ok());
}

#[test]
Expand Down

0 comments on commit 16aaaf7

Please sign in to comment.