Skip to content

Commit

Permalink
feat(psa): add library to module.
Browse files Browse the repository at this point in the history
  • Loading branch information
ynfeng committed Feb 23, 2021
1 parent aab007b commit 7a23550
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions psa/src/psa_module.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
use crate::pas_content_root::ContentRoot;
use crate::psa_facet::Facet;
use crate::psa_library::Library;

pub struct Module {
pub name: String,
pub path: String,
pub facets: Vec<Facet>,
pub libraries: Vec<Library>,
pub content_root: ContentRoot,
}

Expand All @@ -13,11 +15,16 @@ impl Module {
self.facets.push(facet);
}

pub fn add_library(&mut self, lib: Library) {
self.libraries.push(lib);
}

pub fn new(name: &str, path: &str) -> Self {
Module {
name: name.to_string(),
path: path.to_string(),
facets: vec![],
libraries: vec![],
content_root: ContentRoot::default(),
}
}
Expand All @@ -26,6 +33,7 @@ impl Module {
#[cfg(test)]
mod tests {
use crate::psa_facet::Facet;
use crate::psa_library::{Library, LibraryScope};
use crate::psa_module::Module;

#[test]
Expand All @@ -46,4 +54,19 @@ mod tests {

assert_eq!(module.facets.len(), 1);
}

#[test]
fn should_add_library() {
let mut module = Module::new("foo", "test/path");
let lib = Library {
group: "org.springframework.boot".to_string(),
name: "spring-boot-starter-web".to_string(),
version: "1.0.0-RELEASE".to_string(),
scope: LibraryScope::Compile,
};

module.add_library(lib);

assert_eq!(module.libraries.len(), 1);
}
}

0 comments on commit 7a23550

Please sign in to comment.