Skip to content

Commit 01a8370

Browse files
committed
fix(tests): define a helper function to reset lightningd to a valid commit
Reset `lightningd` plugins directory to a commit where `summary` and `helpme` plugins are present Signed-off-by: Tarek <[email protected]>
1 parent f9f98d3 commit 01a8370

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

tests/src/coffee_integration_tests.rs

+7
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use coffee_testing::prelude::tempfile;
1111
use coffee_testing::{CoffeeTesting, CoffeeTestingArgs};
1212

1313
use crate::init;
14+
use crate::reset_plugins;
1415

1516
#[tokio::test]
1617
pub async fn init_coffee_test() -> anyhow::Result<()> {
@@ -145,6 +146,12 @@ pub async fn test_add_remove_plugins() {
145146
.await
146147
.unwrap();
147148

149+
// Reset the plugins directory to a commit where summary and helpme plugins are present
150+
reset_plugins(&format!(
151+
"{}/.coffee/repositories/lightningd",
152+
manager.root_path().to_owned().path().to_str().unwrap()
153+
));
154+
148155
// Get the list of plugins available in the remote repository
149156
let result = manager.coffee().get_plugins_in_remote(repo_name).await;
150157
assert!(result.is_ok(), "{:?}", result);

tests/src/lib.rs

+27
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,30 @@ fn init() {
2020
logger::init(log::Level::Debug).expect("initializing logger for the first time");
2121
});
2222
}
23+
24+
/// Resets the lightningd plugins directory at the specified root path to the commit
25+
/// with the hash `009a0fbad8edc34a6c0e481c34ce8001708853ec`.
26+
///
27+
/// This is a workaround to enable our CI to work with the current state of lightningd remote repo.
28+
///
29+
/// Many of our integration tests rely on "summary" and "helpme" plugins,
30+
/// which have been deprecated and removed so we need to reset the plugins directory to a commit
31+
/// where these plugins are still present.
32+
pub fn reset_plugins(root_path: &str) {
33+
let output = std::process::Command::new("git")
34+
.args(&[
35+
"reset",
36+
"--hard",
37+
"009a0fbad8edc34a6c0e481c34ce8001708853ec",
38+
])
39+
.current_dir(root_path)
40+
.output()
41+
.expect("failed to execute process");
42+
43+
if !output.status.success() {
44+
panic!(
45+
"failed to reset plugins: {}",
46+
String::from_utf8_lossy(&output.stderr)
47+
);
48+
}
49+
}

0 commit comments

Comments
 (0)