Skip to content

Commit

Permalink
fix(project): Now projects are within their default dirs, not the dir…
Browse files Browse the repository at this point in the history
…s themselves
  • Loading branch information
acovaci committed May 25, 2024
1 parent ab6f49c commit a1489c5
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 21 deletions.
24 changes: 21 additions & 3 deletions src/cli/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,37 @@ fn get_projects(config: ConfigManager) -> Res<Vec<Project>> {

#[cfg(test)]
mod tests {
use std::path::PathBuf;

use super::*;

use plumb::types::Location;

#[test]
fn test_get_projects() {
let config = ConfigManager::try_load(None).unwrap();
let config =
ConfigManager::try_load(Some(&PathBuf::from("tests/fixtures/project_list.yml")))
.unwrap();
let projects = get_projects(config).unwrap();
assert_eq!(
projects,
vec![
Project::new("plumb", Location::new("~/projects/plumb".into(), None)),
Project::new("monad", Location::new("~/projects/monad".into(), None))
Project::new(
"project1",
Location::new("~/projects/project1".into(), None)
),
Project::new(
"project2",
Location::new("~/other_projects/project2".into(), None)
),
Project::new(
"project3",
Location::new("~/projects/project3".into(), None)
),
Project::new(
"project4",
Location::new("~/projects/project4".into(), None)
)
]
);
}
Expand Down
8 changes: 1 addition & 7 deletions src/core/config/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ impl ProjectBuilder {
}

pub fn build(&self, name: &str, location: Option<Location>) -> Project {
Project::new(
name,
location.unwrap_or({
let path = self.location.path().join(name);
Location::new(path, None)
}),
)
Project::new(name, location.unwrap_or(self.location.join(name)))
}
}
2 changes: 1 addition & 1 deletion src/core/config/transcriber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl ConfigTranscriber for PlumbConfig {
Location::new(
project
.path
.unwrap_or(default_project_location.clone().path().to_path_buf()),
.unwrap_or(default_project_location.join(&project.name).path().clone()),
None,
),
)
Expand Down
5 changes: 0 additions & 5 deletions tests/fixtures/manager_load.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,12 @@ locations:
- path: ~/projects
name: projects
- path: ~/other_projects
name:
- path: ~/yet_another_projects
name:
defaults:
projects: projects
projects:
- name: project1
path:
- name: project2
path: ~/other_projects/project2
- name: project3
path:
- name: project4
path:
15 changes: 15 additions & 0 deletions tests/fixtures/project_list.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
locations:
projects:
- path: ~/projects
name: projects
- path: ~/other_projects
- path: ~/yet_another_projects
defaults:
projects: projects
projects:
- name: project1
- name: project2
path: ~/other_projects/project2
- name: project3
- name: project4
6 changes: 3 additions & 3 deletions tests/fixtures/transcriber_dump.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ locations:
projects: projects
projects:
- name: project1
path: ~/projects
path: ~/projects/project1
- name: project2
path: ~/other_projects/project2
- name: project3
path: ~/projects
path: ~/projects/project3
- name: project4
path: ~/projects
path: ~/projects/project4
4 changes: 2 additions & 2 deletions tests/fixtures/transcriber_load.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
locations:
projects:
- path: ~/projects
name: projects
- path: ~/other_projects
name:
- path: ~/projects
name: projects
- path: ~/yet_another_projects
name:
defaults:
Expand Down

0 comments on commit a1489c5

Please sign in to comment.