Skip to content

Commit 0126923

Browse files
committed
add test
1 parent d82c86f commit 0126923

File tree

1 file changed

+31
-4
lines changed

1 file changed

+31
-4
lines changed

Diff for: src/tests/team.rs

+31-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ use crate::{
33
builders::{CrateBuilder, PublishBuilder},
44
new_team, OwnerTeamsResponse, RequestHelper, TestApp,
55
};
6-
use crates_io::models::{Crate, NewTeam};
6+
use crates_io::{
7+
models::{Crate, NewTeam},
8+
schema::teams,
9+
};
710

811
use diesel::*;
912
use http::StatusCode;
@@ -67,14 +70,15 @@ fn one_colon() {
6770
}
6871

6972
#[test]
70-
fn nonexistent_team() {
73+
fn add_nonexistent_team() {
7174
let (app, _, user, token) = TestApp::init().with_token();
7275

7376
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);
7578
});
7679

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");
7882
assert_eq!(response.status(), StatusCode::OK);
7983
assert_eq!(
8084
response.into_json(),
@@ -268,6 +272,29 @@ fn remove_team_as_team_owner() {
268272
);
269273
}
270274

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+
271298
/// Test trying to publish a crate we don't own
272299
#[test]
273300
fn publish_not_owned() {

0 commit comments

Comments
 (0)