Skip to content

Commit eedadbe

Browse files
yodaldevoidsgrif
authored andcommitted
Pull in tests from rust-lang#582
1 parent f1a66c1 commit eedadbe

File tree

3 files changed

+206
-0
lines changed

3 files changed

+206
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
===REQUEST 339
2+
PUT http://alexcrichton-test.s3.amazonaws.com/crates/fyk_max/fyk_max-1.0.0.crate HTTP/1.1
3+
Accept: */*
4+
Proxy-Connection: Keep-Alive
5+
Authorization: AWS AKIAJF3GEK7N44BACDZA:GDxGb6r3SIqo9wXuzHrgMNWekwk=
6+
Content-Length: 0
7+
Host: alexcrichton-test.s3.amazonaws.com
8+
Content-Type: application/x-tar
9+
Date: Sun, 28 Jun 2015 14:07:17 -0700
10+
11+
12+
===RESPONSE 258
13+
HTTP/1.1 200
14+
x-amz-request-id: CB0E925D8E3AB3E8
15+
x-amz-id-2: SiaMwszM1p2TzXlLauvZ6kRKcUCg7HoyBW29vts42w9ArrLwkJWl8vuvPuGFkpM6XGH+YXN852g=
16+
date: Sun, 28 Jun 2015 21:07:51 GMT
17+
etag: "d41d8cd98f00b204e9800998ecf8427e"
18+
content-length: 0
19+
server: AmazonS3
20+
21+
22+
===REQUEST 339
23+
PUT http://alexcrichton-test.s3.amazonaws.com/crates/fyk_max/fyk_max-2.0.0.crate HTTP/1.1
24+
Accept: */*
25+
Proxy-Connection: Keep-Alive
26+
Authorization: AWS AKIAJF3GEK7N44BACDZA:GDxGb6r3SIqo9wXuzHrgMNWekwk=
27+
Content-Length: 0
28+
Host: alexcrichton-test.s3.amazonaws.com
29+
Content-Type: application/x-tar
30+
Date: Sun, 28 Jun 2015 14:07:17 -0700
31+
32+
33+
===RESPONSE 258
34+
HTTP/1.1 200
35+
x-amz-request-id: CB0E925D8E3AB3E8
36+
x-amz-id-2: SiaMwszM1p2TzXlLauvZ6kRKcUCg7HoyBW29vts42w9ArrLwkJWl8vuvPuGFkpM6XGH+YXN852g=
37+
date: Sun, 28 Jun 2015 21:07:51 GMT
38+
etag: "d41d8cd98f00b204e9800998ecf8427e"
39+
content-length: 0
40+
server: AmazonS3
41+
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
===REQUEST 339
2+
PUT http://alexcrichton-test.s3.amazonaws.com/crates/fyk_max/fyk_max-1.0.0.crate HTTP/1.1
3+
Accept: */*
4+
Proxy-Connection: Keep-Alive
5+
Authorization: AWS AKIAJF3GEK7N44BACDZA:GDxGb6r3SIqo9wXuzHrgMNWekwk=
6+
Content-Length: 0
7+
Host: alexcrichton-test.s3.amazonaws.com
8+
Content-Type: application/x-tar
9+
Date: Sun, 28 Jun 2015 14:07:17 -0700
10+
11+
12+
===RESPONSE 258
13+
HTTP/1.1 200
14+
x-amz-request-id: CB0E925D8E3AB3E8
15+
x-amz-id-2: SiaMwszM1p2TzXlLauvZ6kRKcUCg7HoyBW29vts42w9ArrLwkJWl8vuvPuGFkpM6XGH+YXN852g=
16+
date: Sun, 28 Jun 2015 21:07:51 GMT
17+
etag: "d41d8cd98f00b204e9800998ecf8427e"
18+
content-length: 0
19+
server: AmazonS3
20+
21+
22+
===REQUEST 339
23+
PUT http://alexcrichton-test.s3.amazonaws.com/crates/fyk_max/fyk_max-2.0.0.crate HTTP/1.1
24+
Accept: */*
25+
Proxy-Connection: Keep-Alive
26+
Authorization: AWS AKIAJF3GEK7N44BACDZA:GDxGb6r3SIqo9wXuzHrgMNWekwk=
27+
Content-Length: 0
28+
Host: alexcrichton-test.s3.amazonaws.com
29+
Content-Type: application/x-tar
30+
Date: Sun, 28 Jun 2015 14:07:17 -0700
31+
32+
33+
===RESPONSE 258
34+
HTTP/1.1 200
35+
x-amz-request-id: CB0E925D8E3AB3E8
36+
x-amz-id-2: SiaMwszM1p2TzXlLauvZ6kRKcUCg7HoyBW29vts42w9ArrLwkJWl8vuvPuGFkpM6XGH+YXN852g=
37+
date: Sun, 28 Jun 2015 21:07:51 GMT
38+
etag: "d41d8cd98f00b204e9800998ecf8427e"
39+
content-length: 0
40+
server: AmazonS3
41+

src/tests/krate.rs

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,130 @@ fn yank_not_owner() {
882882
::json::<::Bad>(&mut response);
883883
}
884884

885+
#[test]
886+
fn yank_max_version() {
887+
#[derive(RustcDecodable)]
888+
struct O {
889+
ok: bool,
890+
}
891+
let (_b, app, middle) = ::app();
892+
893+
// Upload a new crate
894+
let mut req = ::new_req(app, "fyk_max", "1.0.0");
895+
::mock_user(&mut req, ::user("foo"));
896+
let mut response = ok_resp!(middle.call(&mut req));
897+
898+
// double check the max version
899+
let json: GoodCrate = ::json(&mut response);
900+
assert_eq!(json.krate.max_version, "1.0.0");
901+
902+
// add version 2.0.0
903+
let body = ::new_req_body_version_2(::krate("fyk_max"));
904+
let mut response = ok_resp!(middle.call(req.with_path("/api/v1/crates/new")
905+
.with_method(Method::Put)
906+
.with_body(&body)));
907+
let json: GoodCrate = ::json(&mut response);
908+
assert_eq!(json.krate.max_version, "2.0.0");
909+
910+
// yank version 1.0.0
911+
let mut r = ok_resp!(middle.call(req.with_method(Method::Delete)
912+
.with_path("/api/v1/crates/fyk_max/1.0.0/yank")));
913+
assert!(::json::<O>(&mut r).ok);
914+
let mut response = ok_resp!(middle.call(req.with_method(Method::Get)
915+
.with_path("/api/v1/crates/fyk_max")));
916+
let json: CrateResponse = ::json(&mut response);
917+
assert_eq!(json.krate.max_version, "2.0.0");
918+
919+
// unyank version 1.0.0
920+
let mut r = ok_resp!(middle.call(req.with_method(Method::Put)
921+
.with_path("/api/v1/crates/fyk_max/1.0.0/unyank")));
922+
assert!(::json::<O>(&mut r).ok);
923+
let mut response = ok_resp!(middle.call(req.with_method(Method::Get)
924+
.with_path("/api/v1/crates/fyk_max")));
925+
let json: CrateResponse = ::json(&mut response);
926+
assert_eq!(json.krate.max_version, "2.0.0");
927+
928+
// yank version 2.0.0
929+
let mut r = ok_resp!(middle.call(req.with_method(Method::Delete)
930+
.with_path("/api/v1/crates/fyk_max/2.0.0/yank")));
931+
assert!(::json::<O>(&mut r).ok);
932+
let mut response = ok_resp!(middle.call(req.with_method(Method::Get)
933+
.with_path("/api/v1/crates/fyk_max")));
934+
let json: CrateResponse = ::json(&mut response);
935+
assert_eq!(json.krate.max_version, "1.0.0");
936+
937+
// yank version 1.0.0
938+
let mut r = ok_resp!(middle.call(req.with_method(Method::Delete)
939+
.with_path("/api/v1/crates/fyk_max/1.0.0/yank")));
940+
assert!(::json::<O>(&mut r).ok);
941+
let mut response = ok_resp!(middle.call(req.with_method(Method::Get)
942+
.with_path("/api/v1/crates/fyk_max")));
943+
let json: CrateResponse = ::json(&mut response);
944+
assert_eq!(json.krate.max_version, "0.0.0");
945+
946+
// unyank version 2.0.0
947+
let mut r = ok_resp!(middle.call(req.with_method(Method::Put)
948+
.with_path("/api/v1/crates/fyk_max/2.0.0/unyank")));
949+
assert!(::json::<O>(&mut r).ok);
950+
let mut response = ok_resp!(middle.call(req.with_method(Method::Get)
951+
.with_path("/api/v1/crates/fyk_max")));
952+
let json: CrateResponse = ::json(&mut response);
953+
assert_eq!(json.krate.max_version, "2.0.0");
954+
955+
// unyank version 1.0.0
956+
let mut r = ok_resp!(middle.call(req.with_method(Method::Put)
957+
.with_path("/api/v1/crates/fyk_max/1.0.0/unyank")));
958+
assert!(::json::<O>(&mut r).ok);
959+
let mut response = ok_resp!(middle.call(req.with_method(Method::Get)
960+
.with_path("/api/v1/crates/fyk_max")));
961+
let json: CrateResponse = ::json(&mut response);
962+
assert_eq!(json.krate.max_version, "2.0.0");
963+
}
964+
965+
#[test]
966+
fn publish_after_yank_max_version() {
967+
#[derive(RustcDecodable)]
968+
struct O {
969+
ok: bool,
970+
}
971+
let (_b, app, middle) = ::app();
972+
973+
// Upload a new crate
974+
let mut req = ::new_req(app, "fyk_max", "1.0.0");
975+
::mock_user(&mut req, ::user("foo"));
976+
let mut response = ok_resp!(middle.call(&mut req));
977+
978+
// double check the max version
979+
let json: GoodCrate = ::json(&mut response);
980+
assert_eq!(json.krate.max_version, "1.0.0");
981+
982+
// yank version 1.0.0
983+
let mut r = ok_resp!(middle.call(req.with_method(Method::Delete)
984+
.with_path("/api/v1/crates/fyk_max/1.0.0/yank")));
985+
assert!(::json::<O>(&mut r).ok);
986+
let mut response = ok_resp!(middle.call(req.with_method(Method::Get)
987+
.with_path("/api/v1/crates/fyk_max")));
988+
let json: CrateResponse = ::json(&mut response);
989+
assert_eq!(json.krate.max_version, "0.0.0");
990+
991+
// add version 2.0.0
992+
let body = ::new_req_body_version_2(::krate("fyk_max"));
993+
let mut response = ok_resp!(middle.call(req.with_path("/api/v1/crates/new")
994+
.with_method(Method::Put)
995+
.with_body(&body)));
996+
let json: GoodCrate = ::json(&mut response);
997+
assert_eq!(json.krate.max_version, "2.0.0");
998+
999+
// unyank version 1.0.0
1000+
let mut r = ok_resp!(middle.call(req.with_method(Method::Put)
1001+
.with_path("/api/v1/crates/fyk_max/1.0.0/unyank")));
1002+
assert!(::json::<O>(&mut r).ok);
1003+
let mut response = ok_resp!(middle.call(req.with_method(Method::Get)
1004+
.with_path("/api/v1/crates/fyk_max")));
1005+
let json: CrateResponse = ::json(&mut response);
1006+
assert_eq!(json.krate.max_version, "2.0.0");
1007+
}
1008+
8851009
#[test]
8861010
fn bad_keywords() {
8871011
let (_b, app, middle) = ::app();

0 commit comments

Comments
 (0)