Skip to content

Commit 5264735

Browse files
committed
tests/publish: Add has_lib and bin_names test case
1 parent be243a4 commit 5264735

File tree

3 files changed

+119
-0
lines changed

3 files changed

+119
-0
lines changed

src/tests/krate/publish/manifest.rs

+28
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,31 @@ async fn invalid_rust_version() {
144144
assert_eq!(response.status(), StatusCode::BAD_REQUEST);
145145
assert_json_snapshot!(response.json());
146146
}
147+
148+
#[tokio::test(flavor = "multi_thread")]
149+
async fn test_lib_and_bin_crate() {
150+
let (_app, _anon, _cookie, token) = TestApp::full().with_token();
151+
152+
let publish_builder = PublishBuilder::new("foo", "1.0.0")
153+
.add_file("foo-1.0.0/src/lib.rs", "pub fn foo() {}")
154+
.add_file("foo-1.0.0/src/main.rs", "fn main() {}")
155+
.add_file("foo-1.0.0/src/bin/bar.rs", "fn main() {}");
156+
157+
let response = token.publish_crate(publish_builder).await;
158+
assert_eq!(response.status(), StatusCode::OK);
159+
assert_json_snapshot!(response.json(), {
160+
".crate.created_at" => "[datetime]",
161+
".crate.updated_at" => "[datetime]",
162+
});
163+
164+
let response = token.get::<()>("/api/v1/crates/foo/1.0.0").await;
165+
assert_eq!(response.status(), StatusCode::OK);
166+
assert_json_snapshot!(response.json(), {
167+
".version.id" => any_id_redaction(),
168+
".version.created_at" => "[datetime]",
169+
".version.updated_at" => "[datetime]",
170+
".version.published_by.id" => id_redaction(token.as_model().user_id),
171+
".version.audit_actions[].time" => "[datetime]",
172+
".version.audit_actions[].user.id" => id_redaction(token.as_model().user_id),
173+
});
174+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
source: src/tests/krate/publish/manifest.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": "[id]",
14+
"login": "foo",
15+
"name": null,
16+
"url": "https://github.com/foo"
17+
}
18+
}
19+
],
20+
"bin_names": [
21+
"bar",
22+
"foo"
23+
],
24+
"checksum": "ed125a8d83193391762787872f6363ef11d472fe9e963b984a761f970d63a7a8",
25+
"crate": "foo",
26+
"crate_size": 241,
27+
"created_at": "[datetime]",
28+
"dl_path": "/api/v1/crates/foo/1.0.0/download",
29+
"downloads": 0,
30+
"features": {},
31+
"has_lib": true,
32+
"id": "[id]",
33+
"license": "MIT",
34+
"links": {
35+
"authors": "/api/v1/crates/foo/1.0.0/authors",
36+
"dependencies": "/api/v1/crates/foo/1.0.0/dependencies",
37+
"version_downloads": "/api/v1/crates/foo/1.0.0/downloads"
38+
},
39+
"num": "1.0.0",
40+
"published_by": {
41+
"avatar": null,
42+
"id": "[id]",
43+
"login": "foo",
44+
"name": null,
45+
"url": "https://github.com/foo"
46+
},
47+
"readme_path": "/api/v1/crates/foo/1.0.0/readme",
48+
"rust_version": null,
49+
"updated_at": "[datetime]",
50+
"yanked": false
51+
}
52+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
source: src/tests/krate/publish/manifest.rs
3+
expression: response.json()
4+
---
5+
{
6+
"crate": {
7+
"badges": null,
8+
"categories": null,
9+
"created_at": "[datetime]",
10+
"description": "description",
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)