Skip to content

Commit

Permalink
Update tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
milesj committed Dec 3, 2024
1 parent 8ef48c1 commit 86f9aa9
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 17 deletions.
24 changes: 14 additions & 10 deletions .yarn/versions/af8209b2.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
releases:
"@moonrepo/cli": patch
"@moonrepo/core-linux-arm64-gnu": patch
"@moonrepo/core-linux-arm64-musl": patch
"@moonrepo/core-linux-x64-gnu": patch
"@moonrepo/core-linux-x64-musl": patch
"@moonrepo/core-macos-arm64": patch
"@moonrepo/core-macos-x64": patch
"@moonrepo/core-windows-x64-msvc": patch
'@moonrepo/cli': patch
'@moonrepo/core-linux-arm64-gnu': patch
'@moonrepo/core-linux-arm64-musl': patch
'@moonrepo/core-linux-x64-gnu': patch
'@moonrepo/core-linux-x64-musl': patch
'@moonrepo/core-macos-arm64': patch
'@moonrepo/core-macos-x64': patch
'@moonrepo/core-windows-x64-msvc': patch
'@moonrepo/types': patch

undecided:
- "@moonrepo/types"
declined:
- '@moonrepo/nx-compat'
- '@moonrepo/report'
- '@moonrepo/runtime'
- website
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#### ⚙️ Internal

- Updated proto to v0.43.0 (from 0.42.2).
- Updated wasmtime to v26 (from v23).
- Updated Rust to v1.83.

## 1.30.2

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ A template for testing all variable config combinations.
Error: codegen::args::parse_failed

× Failed to parse variables from arguments.
╰─▶ × invalid value 'abc' for '--number <number>': invalid digit found
in string
╰─▶ × invalid value 'abc' for '--number <number>': invalid digit found in
string
107 changes: 102 additions & 5 deletions crates/config/tests/toolchain_config_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ node:
assert_eq!(
config.node.unwrap().npm.plugin.unwrap(),
PluginLocator::Url(Box::new(UrlLocator {
url: "https://github.com/moonrepo/tools/releases/download/node_depman_tool-v0.14.0/node_depman_tool.wasm".into()
url: "https://github.com/moonrepo/tools/releases/download/node_depman_tool-v0.14.1/node_depman_tool.wasm".into()
}))
);
}
Expand Down Expand Up @@ -727,7 +727,7 @@ node:
assert_eq!(
config.node.unwrap().pnpm.unwrap().plugin.unwrap(),
PluginLocator::Url(Box::new(UrlLocator {
url: "https://github.com/moonrepo/tools/releases/download/node_depman_tool-v0.14.0/node_depman_tool.wasm".into()
url: "https://github.com/moonrepo/tools/releases/download/node_depman_tool-v0.14.1/node_depman_tool.wasm".into()
}))
);
}
Expand All @@ -751,7 +751,7 @@ node:
assert_eq!(
config.node.unwrap().pnpm.unwrap().plugin.unwrap(),
PluginLocator::Url(Box::new(UrlLocator {
url: "https://github.com/moonrepo/tools/releases/download/node_depman_tool-v0.14.0/node_depman_tool.wasm".into()
url: "https://github.com/moonrepo/tools/releases/download/node_depman_tool-v0.14.1/node_depman_tool.wasm".into()
}))
);
}
Expand Down Expand Up @@ -853,7 +853,7 @@ node:
assert_eq!(
config.node.unwrap().yarn.unwrap().plugin.unwrap(),
PluginLocator::Url(Box::new(UrlLocator {
url: "https://github.com/moonrepo/tools/releases/download/node_depman_tool-v0.14.0/node_depman_tool.wasm".into()
url: "https://github.com/moonrepo/tools/releases/download/node_depman_tool-v0.14.1/node_depman_tool.wasm".into()
}))
);
}
Expand All @@ -877,7 +877,7 @@ node:
assert_eq!(
config.node.unwrap().yarn.unwrap().plugin.unwrap(),
PluginLocator::Url(Box::new(UrlLocator {
url: "https://github.com/moonrepo/tools/releases/download/node_depman_tool-v0.14.0/node_depman_tool.wasm".into()
url: "https://github.com/moonrepo/tools/releases/download/node_depman_tool-v0.14.1/node_depman_tool.wasm".into()
}))
);
}
Expand Down Expand Up @@ -1134,6 +1134,103 @@ node:
}
}

mod python {
use super::*;

#[test]
fn enables_via_proto() {
let config = test_load_config(FILENAME, "{}", |path| {
let mut proto = ProtoConfig::default();
proto.versions.insert(
Id::raw("python"),
UnresolvedVersionSpec::parse("1.0.0").unwrap(),
);

load_config_from_root(path, &proto)
});

assert!(config.python.is_some());
assert_eq!(
config.python.unwrap().version.unwrap(),
UnresolvedVersionSpec::parse("1.0.0").unwrap()
);
}

#[test]
fn inherits_plugin_locator() {
let config = test_load_config(FILENAME, "python: {}", |path| {
let mut tools = ProtoConfig::default();
tools.inherit_builtin_plugins();

load_config_from_root(path, &tools)
});

assert_eq!(
config.python.unwrap().plugin.unwrap(),
PluginLocator::Url(Box::new(UrlLocator {
url: "https://github.com/moonrepo/tools/releases/download/python_tool-v0.12.1/python_tool.wasm".into()
}))
);
}

#[test]
#[serial]
fn proto_version_doesnt_override() {
let config = test_load_config(
FILENAME,
r"
python:
version: 1.0.0
",
|path| {
let mut proto = ProtoConfig::default();
proto.versions.insert(
Id::raw("python"),
UnresolvedVersionSpec::parse("2.0.0").unwrap(),
);

load_config_from_root(path, &proto)
},
);

assert!(config.python.is_some());
assert_eq!(
config.python.unwrap().version.unwrap(),
UnresolvedVersionSpec::parse("1.0.0").unwrap()
);
}

#[test]
#[serial]
fn inherits_version_from_env_var() {
env::set_var("MOON_PYTHON_VERSION", "1.0.0");

let config = test_load_config(
FILENAME,
r"
python:
version: 3.0.0
",
|path| {
let mut proto = ProtoConfig::default();
proto.versions.insert(
Id::raw("python"),
UnresolvedVersionSpec::parse("2.0.0").unwrap(),
);

load_config_from_root(path, &proto)
},
);

env::remove_var("MOON_PYTHON_VERSION");

assert_eq!(
config.python.unwrap().version.unwrap(),
UnresolvedVersionSpec::parse("1.0.0").unwrap()
);
}
}

mod rust {
use super::*;

Expand Down

0 comments on commit 86f9aa9

Please sign in to comment.