Skip to content

Commit 27f8f00

Browse files
yodaldevoidsgrif
authored andcommitted
Pull in tests from #582
1 parent 6b3d53d commit 27f8f00

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
@@ -865,6 +865,130 @@ fn yank_not_owner() {
865865
::json::<::Bad>(&mut response);
866866
}
867867

868+
#[test]
869+
fn yank_max_version() {
870+
#[derive(RustcDecodable)]
871+
struct O {
872+
ok: bool,
873+
}
874+
let (_b, app, middle) = ::app();
875+
876+
// Upload a new crate
877+
let mut req = ::new_req(app, "fyk_max", "1.0.0");
878+
::mock_user(&mut req, ::user("foo"));
879+
let mut response = ok_resp!(middle.call(&mut req));
880+
881+
// double check the max version
882+
let json: GoodCrate = ::json(&mut response);
883+
assert_eq!(json.krate.max_version, "1.0.0");
884+
885+
// add version 2.0.0
886+
let body = ::new_req_body_version_2(::krate("fyk_max"));
887+
let mut response = ok_resp!(middle.call(req.with_path("/api/v1/crates/new")
888+
.with_method(Method::Put)
889+
.with_body(&body)));
890+
let json: GoodCrate = ::json(&mut response);
891+
assert_eq!(json.krate.max_version, "2.0.0");
892+
893+
// yank version 1.0.0
894+
let mut r = ok_resp!(middle.call(req.with_method(Method::Delete)
895+
.with_path("/api/v1/crates/fyk_max/1.0.0/yank")));
896+
assert!(::json::<O>(&mut r).ok);
897+
let mut response = ok_resp!(middle.call(req.with_method(Method::Get)
898+
.with_path("/api/v1/crates/fyk_max")));
899+
let json: CrateResponse = ::json(&mut response);
900+
assert_eq!(json.krate.max_version, "2.0.0");
901+
902+
// unyank version 1.0.0
903+
let mut r = ok_resp!(middle.call(req.with_method(Method::Put)
904+
.with_path("/api/v1/crates/fyk_max/1.0.0/unyank")));
905+
assert!(::json::<O>(&mut r).ok);
906+
let mut response = ok_resp!(middle.call(req.with_method(Method::Get)
907+
.with_path("/api/v1/crates/fyk_max")));
908+
let json: CrateResponse = ::json(&mut response);
909+
assert_eq!(json.krate.max_version, "2.0.0");
910+
911+
// yank version 2.0.0
912+
let mut r = ok_resp!(middle.call(req.with_method(Method::Delete)
913+
.with_path("/api/v1/crates/fyk_max/2.0.0/yank")));
914+
assert!(::json::<O>(&mut r).ok);
915+
let mut response = ok_resp!(middle.call(req.with_method(Method::Get)
916+
.with_path("/api/v1/crates/fyk_max")));
917+
let json: CrateResponse = ::json(&mut response);
918+
assert_eq!(json.krate.max_version, "1.0.0");
919+
920+
// yank version 1.0.0
921+
let mut r = ok_resp!(middle.call(req.with_method(Method::Delete)
922+
.with_path("/api/v1/crates/fyk_max/1.0.0/yank")));
923+
assert!(::json::<O>(&mut r).ok);
924+
let mut response = ok_resp!(middle.call(req.with_method(Method::Get)
925+
.with_path("/api/v1/crates/fyk_max")));
926+
let json: CrateResponse = ::json(&mut response);
927+
assert_eq!(json.krate.max_version, "0.0.0");
928+
929+
// unyank version 2.0.0
930+
let mut r = ok_resp!(middle.call(req.with_method(Method::Put)
931+
.with_path("/api/v1/crates/fyk_max/2.0.0/unyank")));
932+
assert!(::json::<O>(&mut r).ok);
933+
let mut response = ok_resp!(middle.call(req.with_method(Method::Get)
934+
.with_path("/api/v1/crates/fyk_max")));
935+
let json: CrateResponse = ::json(&mut response);
936+
assert_eq!(json.krate.max_version, "2.0.0");
937+
938+
// unyank version 1.0.0
939+
let mut r = ok_resp!(middle.call(req.with_method(Method::Put)
940+
.with_path("/api/v1/crates/fyk_max/1.0.0/unyank")));
941+
assert!(::json::<O>(&mut r).ok);
942+
let mut response = ok_resp!(middle.call(req.with_method(Method::Get)
943+
.with_path("/api/v1/crates/fyk_max")));
944+
let json: CrateResponse = ::json(&mut response);
945+
assert_eq!(json.krate.max_version, "2.0.0");
946+
}
947+
948+
#[test]
949+
fn publish_after_yank_max_version() {
950+
#[derive(RustcDecodable)]
951+
struct O {
952+
ok: bool,
953+
}
954+
let (_b, app, middle) = ::app();
955+
956+
// Upload a new crate
957+
let mut req = ::new_req(app, "fyk_max", "1.0.0");
958+
::mock_user(&mut req, ::user("foo"));
959+
let mut response = ok_resp!(middle.call(&mut req));
960+
961+
// double check the max version
962+
let json: GoodCrate = ::json(&mut response);
963+
assert_eq!(json.krate.max_version, "1.0.0");
964+
965+
// yank version 1.0.0
966+
let mut r = ok_resp!(middle.call(req.with_method(Method::Delete)
967+
.with_path("/api/v1/crates/fyk_max/1.0.0/yank")));
968+
assert!(::json::<O>(&mut r).ok);
969+
let mut response = ok_resp!(middle.call(req.with_method(Method::Get)
970+
.with_path("/api/v1/crates/fyk_max")));
971+
let json: CrateResponse = ::json(&mut response);
972+
assert_eq!(json.krate.max_version, "0.0.0");
973+
974+
// add version 2.0.0
975+
let body = ::new_req_body_version_2(::krate("fyk_max"));
976+
let mut response = ok_resp!(middle.call(req.with_path("/api/v1/crates/new")
977+
.with_method(Method::Put)
978+
.with_body(&body)));
979+
let json: GoodCrate = ::json(&mut response);
980+
assert_eq!(json.krate.max_version, "2.0.0");
981+
982+
// unyank version 1.0.0
983+
let mut r = ok_resp!(middle.call(req.with_method(Method::Put)
984+
.with_path("/api/v1/crates/fyk_max/1.0.0/unyank")));
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, "2.0.0");
990+
}
991+
868992
#[test]
869993
fn bad_keywords() {
870994
let (_b, app, middle) = ::app();

0 commit comments

Comments
 (0)