Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(modules): cover pin-ahead warning for locally served modules

Steven Enamakelecfa6ee33b13
diff --git a/crates/openhuman-core/src/modules/ops_tests.rs b/crates/openhuman-core/src/modules/ops_tests.rs
index d9b4408f8a..13e54474d6 100644
--- a/crates/openhuman-core/src/modules/ops_tests.rs
+++ b/crates/openhuman-core/src/modules/ops_tests.rs
@@ -645,3 +645,34 @@ async fn a_failing_linked_factory_is_reported_without_its_error_detail() {
assert!(!error.contains("secret-token"), "{error}");
assert!(!error.contains("/home"), "{error}");
}
+
+#[test]
+fn a_debug_build_warns_when_a_local_build_is_served_ahead_of_its_pin() {
+ use crate::modules::source::pin_ahead_warning;
+ use crate::modules::types::ModuleSource;
+
+ for served in [ModuleSource::Linked, ModuleSource::Source] {
+ let line = pin_ahead_warning("tinydocs", served, Some("tinysearch, tinydocs"), true)
+ .expect("an ahead id served locally warns");
+ assert!(line.contains("id=tinydocs"));
+ assert!(line.contains("gitlink ahead of released pin"));
+ assert!(line.contains("release-and-repin"));
+ }
+}
+
+#[test]
+fn the_ahead_warning_is_silent_for_released_modules_other_ids_and_release_builds() {
+ use crate::modules::source::pin_ahead_warning;
+ use crate::modules::types::ModuleSource;
+
+ // Released and explicit-file modules are not a locally compiled pin.
+ for served in [ModuleSource::Release, ModuleSource::LocalFile] {
+ assert!(pin_ahead_warning("tinydocs", served, Some("tinydocs"), true).is_none());
+ }
+ // Not in the list, an id that merely contains the name, no list at all.
+ assert!(pin_ahead_warning("tinydocs", ModuleSource::Source, Some("tinydocs2"), true).is_none());
+ assert!(pin_ahead_warning("tinydocs", ModuleSource::Source, Some(""), true).is_none());
+ assert!(pin_ahead_warning("tinydocs", ModuleSource::Source, None, true).is_none());
+ // A release build never warns.
+ assert!(pin_ahead_warning("tinydocs", ModuleSource::Source, Some("tinydocs"), false).is_none());
+}