Skip to content

Commit 4a54f2b

Browse files
committed
Add "links" field test
1 parent 7b5c61a commit 4a54f2b

File tree

5 files changed

+143
-0
lines changed

5 files changed

+143
-0
lines changed

src/tests/krate/publish/links.rs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
use crate::builders::PublishBuilder;
2+
use crate::util::insta::{self, assert_json_snapshot};
3+
use crate::util::{RequestHelper, TestApp};
4+
use http::StatusCode;
5+
6+
#[tokio::test(flavor = "multi_thread")]
7+
async fn test_crate_with_links_field() {
8+
let (app, anon, _, token) = TestApp::full().with_token();
9+
10+
let manifest = r#"
11+
[package]
12+
name = "foo"
13+
version = "1.0.0"
14+
description = "foo?!"
15+
license = "MIT"
16+
links = "git2"
17+
"#;
18+
19+
let pb = PublishBuilder::new("foo", "1.0.0").custom_manifest(manifest);
20+
let response = token.publish_crate(pb).await;
21+
assert_json_snapshot!(response.json(), {
22+
".crate.created_at" => "[datetime]",
23+
".crate.updated_at" => "[datetime]",
24+
});
25+
assert_eq!(response.status(), StatusCode::OK);
26+
27+
let response = anon.get::<()>("/api/v1/crates/foo/1.0.0").await;
28+
assert_json_snapshot!(response.json(), {
29+
".version.id" => insta::any_id_redaction(),
30+
".version.created_at" => "[datetime]",
31+
".version.updated_at" => "[datetime]",
32+
".version.audit_actions[].time" => "[datetime]",
33+
".version.published_by.id" => insta::any_id_redaction(),
34+
});
35+
assert_eq!(response.status(), StatusCode::OK);
36+
37+
let crates = app.crates_from_index_head("foo");
38+
assert_json_snapshot!(crates);
39+
}

src/tests/krate/publish/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ mod features;
99
mod git;
1010
mod inheritance;
1111
mod keywords;
12+
mod links;
1213
mod manifest;
1314
mod max_size;
1415
mod rate_limit;
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
source: src/tests/krate/publish/links.rs
3+
expression: response.json()
4+
---
5+
{
6+
"version": {
7+
"audit_actions": [
8+
{
9+
"action": "publish",
10+
"time": "[datetime]",
11+
"user": {
12+
"avatar": null,
13+
"id": 1,
14+
"login": "foo",
15+
"name": null,
16+
"url": "https://github.com/foo"
17+
}
18+
}
19+
],
20+
"bin_names": [],
21+
"checksum": "5631ca06d228e58274bbd8d6a3e81f7138a9e227a84bd63ecedb78afbc8144ea",
22+
"crate": "foo",
23+
"crate_size": 162,
24+
"created_at": "[datetime]",
25+
"dl_path": "/api/v1/crates/foo/1.0.0/download",
26+
"downloads": 0,
27+
"features": {},
28+
"has_lib": false,
29+
"id": "[id]",
30+
"license": "MIT",
31+
"links": {
32+
"authors": "/api/v1/crates/foo/1.0.0/authors",
33+
"dependencies": "/api/v1/crates/foo/1.0.0/dependencies",
34+
"version_downloads": "/api/v1/crates/foo/1.0.0/downloads"
35+
},
36+
"num": "1.0.0",
37+
"published_by": {
38+
"avatar": null,
39+
"id": "[id]",
40+
"login": "foo",
41+
"name": null,
42+
"url": "https://github.com/foo"
43+
},
44+
"readme_path": "/api/v1/crates/foo/1.0.0/readme",
45+
"rust_version": null,
46+
"updated_at": "[datetime]",
47+
"yanked": false
48+
}
49+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
source: src/tests/krate/publish/links.rs
3+
expression: crates
4+
---
5+
[
6+
{
7+
"name": "foo",
8+
"vers": "1.0.0",
9+
"deps": [],
10+
"cksum": "5631ca06d228e58274bbd8d6a3e81f7138a9e227a84bd63ecedb78afbc8144ea",
11+
"features": {},
12+
"yanked": false,
13+
"links": "git2"
14+
}
15+
]
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
source: src/tests/krate/publish/links.rs
3+
expression: response.json()
4+
---
5+
{
6+
"crate": {
7+
"badges": null,
8+
"categories": null,
9+
"created_at": "[datetime]",
10+
"description": "foo?!",
11+
"documentation": null,
12+
"downloads": 0,
13+
"exact_match": false,
14+
"homepage": null,
15+
"id": "foo",
16+
"keywords": null,
17+
"links": {
18+
"owner_team": "/api/v1/crates/foo/owner_team",
19+
"owner_user": "/api/v1/crates/foo/owner_user",
20+
"owners": "/api/v1/crates/foo/owners",
21+
"reverse_dependencies": "/api/v1/crates/foo/reverse_dependencies",
22+
"version_downloads": "/api/v1/crates/foo/downloads",
23+
"versions": "/api/v1/crates/foo/versions"
24+
},
25+
"max_stable_version": "1.0.0",
26+
"max_version": "1.0.0",
27+
"name": "foo",
28+
"newest_version": "1.0.0",
29+
"recent_downloads": null,
30+
"repository": null,
31+
"updated_at": "[datetime]",
32+
"versions": null
33+
},
34+
"warnings": {
35+
"invalid_badges": [],
36+
"invalid_categories": [],
37+
"other": []
38+
}
39+
}

0 commit comments

Comments
 (0)