diff --git a/src/gitlab/client.rs b/src/gitlab/client.rs index fe1eeed..6d09d63 100644 --- a/src/gitlab/client.rs +++ b/src/gitlab/client.rs @@ -156,7 +156,7 @@ impl Client { pub async fn make_project( &self, - name: String, + slug: String, group_id: types::GroupId, info: &types::Project, ) -> reqwest::Result { @@ -168,7 +168,8 @@ impl Client { namespace_id: types::GroupId, } - let path = name.clone(); + let name = info.name.clone(); + let path = slug.clone(); let namespace_id = group_id; let description = self.make_project_description(info.description.clone()); @@ -252,7 +253,7 @@ impl Client { project_info: &types::Project, ) -> reqwest::Result { let mut parent_id = root_group.as_ref().map(|gr| gr.id); - let project_name = path.pop().expect("invalid project path"); + let project_slug = path.pop().expect("invalid project path"); let mut current_namespace = root_group .as_ref() .map(|gr| gr.full_path.clone()) @@ -274,13 +275,13 @@ impl Client { } match self - .project_exist(format!("{}/{}", current_namespace, project_name)) + .project_exist(format!("{}/{}", current_namespace, project_slug)) .await? { Some(p) => self.update_project(&p, project_info).await, None => { self.make_project( - project_name, + project_slug, parent_id.unwrap_or_else(|| { panic!( "Parent group for project {} not found", diff --git a/tests/integration_test.rs b/tests/integration_test.rs index e11d5ad..636f8dc 100644 --- a/tests/integration_test.rs +++ b/tests/integration_test.rs @@ -57,6 +57,7 @@ mod tests { #[derive(Deserialize)] struct Project { description: String, + name: String, } let url_prefix = format!("{}api/v4/projects", GITLAB_HOST); @@ -90,14 +91,19 @@ mod tests { } // check description - let projects = vec![p1_name, p2_name, p3_name]; - for project in projects { + let projects = vec![ + (p1_name, "project_1"), + (p2_name, "Project 2"), + (p3_name, "project_3"), + ]; + for (project, project_name) in projects { let url = format!("{}/{}?access_token={}", url_prefix, project, gitlab_token); let resp = client.get(url).send().unwrap().error_for_status().unwrap(); let p = resp.json::().unwrap(); let d_time_str = p.description.split(" 🦞 Synced: ").last().unwrap(); let d_time = DateTime::parse_from_rfc3339(d_time_str).unwrap(); assert!(d_time >= start_time); + assert!(p.name == project_name); } }