@@ -3,7 +3,10 @@ use crate::{
3
3
builders:: { CrateBuilder , PublishBuilder } ,
4
4
new_team, OwnerTeamsResponse , RequestHelper , TestApp ,
5
5
} ;
6
- use crates_io:: models:: { Crate , NewTeam } ;
6
+ use crates_io:: {
7
+ models:: { Crate , NewTeam } ,
8
+ schema:: teams,
9
+ } ;
7
10
8
11
use diesel:: * ;
9
12
use http:: StatusCode ;
@@ -67,14 +70,15 @@ fn one_colon() {
67
70
}
68
71
69
72
#[ test]
70
- fn nonexistent_team ( ) {
73
+ fn add_nonexistent_team ( ) {
71
74
let ( app, _, user, token) = TestApp :: init ( ) . with_token ( ) ;
72
75
73
76
app. db ( |conn| {
74
- CrateBuilder :: new ( "foo_nonexistent " , user. as_model ( ) . id ) . expect_build ( conn) ;
77
+ CrateBuilder :: new ( "foo_add_nonexistent " , user. as_model ( ) . id ) . expect_build ( conn) ;
75
78
} ) ;
76
79
77
- let response = token. add_named_owner ( "foo_nonexistent" , "github:test-org:this-does-not-exist" ) ;
80
+ let response =
81
+ token. add_named_owner ( "foo_add_nonexistent" , "github:test-org:this-does-not-exist" ) ;
78
82
assert_eq ! ( response. status( ) , StatusCode :: OK ) ;
79
83
assert_eq ! (
80
84
response. into_json( ) ,
@@ -268,6 +272,29 @@ fn remove_team_as_team_owner() {
268
272
) ;
269
273
}
270
274
275
+ #[ test]
276
+ fn remove_nonexistent_team ( ) {
277
+ let ( app, _, user, token) = TestApp :: init ( ) . with_token ( ) ;
278
+
279
+ app. db ( |conn| {
280
+ CrateBuilder :: new ( "foo_remove_nonexistent" , user. as_model ( ) . id ) . expect_build ( conn) ;
281
+ insert_into ( teams:: table)
282
+ . values ( (
283
+ teams:: login. eq ( "github:test-org:this-does-not-exist" ) ,
284
+ teams:: github_id. eq ( 5678 ) ,
285
+ ) )
286
+ . execute ( conn)
287
+ . expect ( "couldn't insert nonexistent team" )
288
+ } ) ;
289
+
290
+ token
291
+ . remove_named_owner (
292
+ "foo_remove_nonexistent" ,
293
+ "github:test-org:this-does-not-exist" ,
294
+ )
295
+ . good ( ) ;
296
+ }
297
+
271
298
/// Test trying to publish a crate we don't own
272
299
#[ test]
273
300
fn publish_not_owned ( ) {
0 commit comments