Skip to content

Commit

Permalink
add test for description set
Browse files Browse the repository at this point in the history
  • Loading branch information
hadim committed Dec 18, 2023
1 parent a7dbb94 commit 5941f42
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/cli/project/description/get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub struct Args {}

pub async fn execute(project: Project, _args: Args) -> miette::Result<()> {
// Print the description if it exists
if let Some(description) = project.manifest.parsed.project.description {
if let Some(description) = project.description() {
eprintln!("{}", description);
}
Ok(())
Expand Down
5 changes: 5 additions & 0 deletions src/project/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ impl Project {
&self.manifest.parsed.project.version
}

/// Returns the description of the project
pub fn description(&self) -> &Option<String> {
&self.manifest.parsed.project.description
}

/// Returns the root directory of the project
pub fn root(&self) -> &Path {
&self.root
Expand Down
32 changes: 16 additions & 16 deletions tests/project_tests.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
mod common;

use crate::{common::package_database::PackageDatabase, common::PixiControl};
use pixi::cli::project::description;
use rattler_conda_types::{Channel, ChannelConfig};
use tempfile::TempDir;
use url::Url;
Expand Down Expand Up @@ -49,27 +50,26 @@ async fn add_channel() {
}

#[tokio::test]
async fn description() {
async fn description_set() {
// Get a pixi instance
let pixi = PixiControl::new().unwrap();
pixi.init().await.unwrap();

let _command = "project description set \"Hello world\"";
let new_description = "Hello description 1234567890!";

// // Set the description
// let result = pixi
// .run(run::Args {
// task: command.split(" ").map(|s| s.to_string()).collect(),
// ..Default::default()
// })
// .await
// .unwrap();

// println!("{:?}", result);
// Set the description
description::execute(description::Args {
command: description::Command::Set(description::set::Args {
description: new_description.to_string(),
}),
manifest_path: Some(pixi.project().unwrap().manifest_path()),
})
.await
.unwrap();

// assert_eq!(result.exit_code, 0);
// assert_eq!(result.stdout.trim(), "Python 3.11.0");
// assert!(result.stderr.is_empty());
// Load the project
let project = pixi.project().unwrap();

// let project = pixi.project().unwrap();
// Check that the description is set
assert_eq!(project.description().as_ref().unwrap(), new_description);
}

0 comments on commit 5941f42

Please sign in to comment.