|
1 |
| -use crate::models::{Crate, NewTeam}; |
2 |
| -use crate::schema::teams; |
| 1 | +use crate::models::{Crate, CrateOwner, NewTeam}; |
3 | 2 | use crate::tests::builders::{CrateBuilder, PublishBuilder};
|
4 | 3 | use crate::tests::{add_team_to_crate, new_team, OwnerTeamsResponse, RequestHelper, TestApp};
|
5 | 4 |
|
@@ -284,26 +283,36 @@ async fn remove_nonexistent_team() {
|
284 | 283 | let (app, _, user, token) = TestApp::init().with_token().await;
|
285 | 284 | let mut conn = app.db_conn().await;
|
286 | 285 |
|
287 |
| - CrateBuilder::new("foo_remove_nonexistent", user.as_model().id) |
| 286 | + let krate = CrateBuilder::new("foo_remove_nonexistent", user.as_model().id) |
288 | 287 | .expect_build(&mut conn)
|
289 | 288 | .await;
|
290 |
| - insert_into(teams::table) |
291 |
| - .values(( |
292 |
| - teams::login.eq("github:test-org:this-does-not-exist"), |
293 |
| - teams::github_id.eq(5678), |
294 |
| - )) |
295 |
| - .execute(&mut conn) |
| 289 | + |
| 290 | + let team = NewTeam::builder() |
| 291 | + .login("github:test-org:this-does-not-exist") |
| 292 | + .github_id(5678) |
| 293 | + .org_id(1234) |
| 294 | + .build() |
| 295 | + .create_or_update(&mut conn) |
296 | 296 | .await
|
297 | 297 | .expect("couldn't insert nonexistent team");
|
298 | 298 |
|
| 299 | + CrateOwner::builder() |
| 300 | + .crate_id(krate.id) |
| 301 | + .team_id(team.id) |
| 302 | + .created_by(user.as_model().id) |
| 303 | + .build() |
| 304 | + .insert(&mut conn) |
| 305 | + .await |
| 306 | + .unwrap(); |
| 307 | + |
299 | 308 | let response = token
|
300 | 309 | .remove_named_owner(
|
301 | 310 | "foo_remove_nonexistent",
|
302 | 311 | "github:test-org:this-does-not-exist",
|
303 | 312 | )
|
304 | 313 | .await;
|
305 |
| - assert_eq!(response.status(), StatusCode::BAD_REQUEST); |
306 |
| - assert_snapshot!(response.text(), @r#"{"errors":[{"detail":"could not find owner with login `github:test-org:this-does-not-exist`"}]}"#); |
| 314 | + assert_eq!(response.status(), StatusCode::OK); |
| 315 | + assert_snapshot!(response.text(), @r#"{"msg":"owners successfully removed","ok":true}"#); |
307 | 316 | }
|
308 | 317 |
|
309 | 318 | /// Test trying to publish a crate we don't own
|
|
0 commit comments