Skip to content

Commit

Permalink
test: added test to check if correct tables are added to toml file (#156
Browse files Browse the repository at this point in the history
)
  • Loading branch information
tdejager authored Jun 30, 2023
1 parent 49630ec commit 95c2515
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/project/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pub mod environment;
mod manifest;
pub mod manifest;
mod serde;

use crate::consts;
Expand All @@ -23,9 +23,9 @@ use toml_edit::{Array, Document, Item, Table, TomlError, Value};
#[derive(Debug)]
pub struct Project {
root: PathBuf,
pub(crate) source: String,
pub source: String,
doc: Document,
pub(crate) manifest: ProjectManifest,
pub manifest: ProjectManifest,
}

impl Project {
Expand Down
19 changes: 18 additions & 1 deletion tests/add_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,24 @@ async fn add_functionality_union() {
.unwrap();
pixi.add("libidk").set_type(SpecType::Build).await.unwrap();

// Lock file should contain all packages
// Toml should contain the correct sections
// We test if the toml file that is saved is correct
// by checking if we get the correct values back in the manifest
// We know this works because we test the manifest in another test
// Where we check if the sections are put in the correct variables
let project = pixi.project().unwrap();

// Should contain all added dependencies
let (name, _) = project.manifest.dependencies.first().unwrap();
assert_eq!(name, "rattler");
let host_deps = project.manifest.host_dependencies.unwrap();
let (name, _) = host_deps.first().unwrap();
assert_eq!(name, "libcomputer");
let build_deps = project.manifest.build_dependencies.unwrap();
let (name, _) = build_deps.first().unwrap();
assert_eq!(name, "libidk");

// Lock file should contain all packages as well
let lock = pixi.lock_file().await.unwrap();
assert!(lock.contains_matchspec("rattler==1"));
assert!(lock.contains_matchspec("libcomputer==1.2"));
Expand Down

0 comments on commit 95c2515

Please sign in to comment.