Skip to content

Commit 5f8fbb9

Browse files
committed
Add unit tests for the patch API
Signed-off-by: Rustin170506 <[email protected]>
1 parent e8907de commit 5f8fbb9

10 files changed

+542
-2
lines changed

src/tests/all.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ pub struct CrateResponse {
6565
versions: Option<Vec<EncodableVersion>>,
6666
keywords: Option<Vec<EncodableKeyword>>,
6767
}
68-
#[derive(Deserialize)]
68+
#[derive(Serialize, Deserialize)]
6969
pub struct VersionResponse {
7070
version: EncodableVersion,
7171
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
---
2+
source: src/tests/krate/yanking.rs
3+
expression: json
4+
---
5+
{
6+
"version": {
7+
"id": 1,
8+
"crate": "patchable",
9+
"num": "1.0.0",
10+
"dl_path": "/api/v1/crates/patchable/1.0.0/download",
11+
"readme_path": "/api/v1/crates/patchable/1.0.0/readme",
12+
"updated_at": "2024-09-18T14:27:21.928149+00:00",
13+
"created_at": "2024-09-18T14:27:21.355906+00:00",
14+
"downloads": 0,
15+
"features": {},
16+
"yanked": true,
17+
"yank_message": "Yanking reason",
18+
"lib_links": null,
19+
"license": "MIT",
20+
"links": {
21+
"dependencies": "/api/v1/crates/patchable/1.0.0/dependencies",
22+
"version_downloads": "/api/v1/crates/patchable/1.0.0/downloads",
23+
"authors": "/api/v1/crates/patchable/1.0.0/authors"
24+
},
25+
"crate_size": 151,
26+
"published_by": {
27+
"id": 1,
28+
"login": "foo",
29+
"name": null,
30+
"avatar": null,
31+
"url": "https://github.com/foo"
32+
},
33+
"audit_actions": [
34+
{
35+
"action": "publish",
36+
"user": {
37+
"id": 1,
38+
"login": "foo",
39+
"name": null,
40+
"avatar": null,
41+
"url": "https://github.com/foo"
42+
},
43+
"time": "2024-09-18T14:27:21.355906+00:00"
44+
},
45+
{
46+
"action": "yank",
47+
"user": {
48+
"id": 1,
49+
"login": "foo",
50+
"name": null,
51+
"avatar": null,
52+
"url": "https://github.com/foo"
53+
},
54+
"time": "2024-09-18T14:27:21.932571+00:00"
55+
}
56+
],
57+
"checksum": "ddfc395ab340f413ee1d1ed0afce51a7c9df1c99c551fed5aef76edd4abe4048",
58+
"rust_version": null,
59+
"has_lib": false,
60+
"bin_names": []
61+
}
62+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
source: src/tests/krate/yanking.rs
3+
expression: response
4+
---
5+
{
6+
"version": {
7+
"id": 1,
8+
"crate": "patchable",
9+
"num": "1.0.0",
10+
"dl_path": "/api/v1/crates/patchable/1.0.0/download",
11+
"readme_path": "/api/v1/crates/patchable/1.0.0/readme",
12+
"updated_at": "2024-09-18T14:27:21.928149+00:00",
13+
"created_at": "2024-09-18T14:27:21.355906+00:00",
14+
"downloads": 0,
15+
"features": {},
16+
"yanked": true,
17+
"yank_message": "Updated reason",
18+
"lib_links": null,
19+
"license": "MIT",
20+
"links": {
21+
"dependencies": "/api/v1/crates/patchable/1.0.0/dependencies",
22+
"version_downloads": "/api/v1/crates/patchable/1.0.0/downloads",
23+
"authors": "/api/v1/crates/patchable/1.0.0/authors"
24+
},
25+
"crate_size": 151,
26+
"published_by": {
27+
"id": 1,
28+
"login": "foo",
29+
"name": null,
30+
"avatar": null,
31+
"url": "https://github.com/foo"
32+
},
33+
"audit_actions": [
34+
{
35+
"action": "publish",
36+
"user": {
37+
"id": 1,
38+
"login": "foo",
39+
"name": null,
40+
"avatar": null,
41+
"url": "https://github.com/foo"
42+
},
43+
"time": "2024-09-18T14:27:21.355906+00:00"
44+
},
45+
{
46+
"action": "yank",
47+
"user": {
48+
"id": 1,
49+
"login": "foo",
50+
"name": null,
51+
"avatar": null,
52+
"url": "https://github.com/foo"
53+
},
54+
"time": "2024-09-18T14:27:21.932571+00:00"
55+
},
56+
{
57+
"action": "yank",
58+
"user": {
59+
"id": 1,
60+
"login": "foo",
61+
"name": null,
62+
"avatar": null,
63+
"url": "https://github.com/foo"
64+
},
65+
"time": "2024-09-18T14:27:22.292030+00:00"
66+
}
67+
],
68+
"checksum": "ddfc395ab340f413ee1d1ed0afce51a7c9df1c99c551fed5aef76edd4abe4048",
69+
"rust_version": null,
70+
"has_lib": false,
71+
"bin_names": []
72+
}
73+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
source: src/tests/krate/yanking.rs
3+
expression: json
4+
---
5+
{
6+
"version": {
7+
"id": 1,
8+
"crate": "patchable",
9+
"num": "1.0.0",
10+
"dl_path": "/api/v1/crates/patchable/1.0.0/download",
11+
"readme_path": "/api/v1/crates/patchable/1.0.0/readme",
12+
"updated_at": "2024-09-18T14:27:22.286252+00:00",
13+
"created_at": "2024-09-18T14:27:21.355906+00:00",
14+
"downloads": 0,
15+
"features": {},
16+
"yanked": true,
17+
"yank_message": "Updated reason",
18+
"lib_links": null,
19+
"license": "MIT",
20+
"links": {
21+
"dependencies": "/api/v1/crates/patchable/1.0.0/dependencies",
22+
"version_downloads": "/api/v1/crates/patchable/1.0.0/downloads",
23+
"authors": "/api/v1/crates/patchable/1.0.0/authors"
24+
},
25+
"crate_size": 151,
26+
"published_by": {
27+
"id": 1,
28+
"login": "foo",
29+
"name": null,
30+
"avatar": null,
31+
"url": "https://github.com/foo"
32+
},
33+
"audit_actions": [
34+
{
35+
"action": "publish",
36+
"user": {
37+
"id": 1,
38+
"login": "foo",
39+
"name": null,
40+
"avatar": null,
41+
"url": "https://github.com/foo"
42+
},
43+
"time": "2024-09-18T14:27:21.355906+00:00"
44+
},
45+
{
46+
"action": "yank",
47+
"user": {
48+
"id": 1,
49+
"login": "foo",
50+
"name": null,
51+
"avatar": null,
52+
"url": "https://github.com/foo"
53+
},
54+
"time": "2024-09-18T14:27:21.932571+00:00"
55+
},
56+
{
57+
"action": "yank",
58+
"user": {
59+
"id": 1,
60+
"login": "foo",
61+
"name": null,
62+
"avatar": null,
63+
"url": "https://github.com/foo"
64+
},
65+
"time": "2024-09-18T14:27:22.292030+00:00"
66+
}
67+
],
68+
"checksum": "ddfc395ab340f413ee1d1ed0afce51a7c9df1c99c551fed5aef76edd4abe4048",
69+
"rust_version": null,
70+
"has_lib": false,
71+
"bin_names": []
72+
}
73+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
source: src/tests/krate/yanking.rs
3+
expression: response
4+
---
5+
{
6+
"version": {
7+
"id": 1,
8+
"crate": "patchable",
9+
"num": "1.0.0",
10+
"dl_path": "/api/v1/crates/patchable/1.0.0/download",
11+
"readme_path": "/api/v1/crates/patchable/1.0.0/readme",
12+
"updated_at": "2024-09-18T14:27:22.286252+00:00",
13+
"created_at": "2024-09-18T14:27:21.355906+00:00",
14+
"downloads": 0,
15+
"features": {},
16+
"yanked": false,
17+
"yank_message": null,
18+
"lib_links": null,
19+
"license": "MIT",
20+
"links": {
21+
"dependencies": "/api/v1/crates/patchable/1.0.0/dependencies",
22+
"version_downloads": "/api/v1/crates/patchable/1.0.0/downloads",
23+
"authors": "/api/v1/crates/patchable/1.0.0/authors"
24+
},
25+
"crate_size": 151,
26+
"published_by": {
27+
"id": 1,
28+
"login": "foo",
29+
"name": null,
30+
"avatar": null,
31+
"url": "https://github.com/foo"
32+
},
33+
"audit_actions": [
34+
{
35+
"action": "publish",
36+
"user": {
37+
"id": 1,
38+
"login": "foo",
39+
"name": null,
40+
"avatar": null,
41+
"url": "https://github.com/foo"
42+
},
43+
"time": "2024-09-18T14:27:21.355906+00:00"
44+
},
45+
{
46+
"action": "yank",
47+
"user": {
48+
"id": 1,
49+
"login": "foo",
50+
"name": null,
51+
"avatar": null,
52+
"url": "https://github.com/foo"
53+
},
54+
"time": "2024-09-18T14:27:21.932571+00:00"
55+
},
56+
{
57+
"action": "yank",
58+
"user": {
59+
"id": 1,
60+
"login": "foo",
61+
"name": null,
62+
"avatar": null,
63+
"url": "https://github.com/foo"
64+
},
65+
"time": "2024-09-18T14:27:22.292030+00:00"
66+
},
67+
{
68+
"action": "unyank",
69+
"user": {
70+
"id": 1,
71+
"login": "foo",
72+
"name": null,
73+
"avatar": null,
74+
"url": "https://github.com/foo"
75+
},
76+
"time": "2024-09-18T14:27:22.497519+00:00"
77+
}
78+
],
79+
"checksum": "ddfc395ab340f413ee1d1ed0afce51a7c9df1c99c551fed5aef76edd4abe4048",
80+
"rust_version": null,
81+
"has_lib": false,
82+
"bin_names": []
83+
}
84+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
source: src/tests/krate/yanking.rs
3+
expression: json
4+
---
5+
{
6+
"version": {
7+
"id": 1,
8+
"crate": "patchable",
9+
"num": "1.0.0",
10+
"dl_path": "/api/v1/crates/patchable/1.0.0/download",
11+
"readme_path": "/api/v1/crates/patchable/1.0.0/readme",
12+
"updated_at": "2024-09-18T14:27:22.494398+00:00",
13+
"created_at": "2024-09-18T14:27:21.355906+00:00",
14+
"downloads": 0,
15+
"features": {},
16+
"yanked": false,
17+
"yank_message": null,
18+
"lib_links": null,
19+
"license": "MIT",
20+
"links": {
21+
"dependencies": "/api/v1/crates/patchable/1.0.0/dependencies",
22+
"version_downloads": "/api/v1/crates/patchable/1.0.0/downloads",
23+
"authors": "/api/v1/crates/patchable/1.0.0/authors"
24+
},
25+
"crate_size": 151,
26+
"published_by": {
27+
"id": 1,
28+
"login": "foo",
29+
"name": null,
30+
"avatar": null,
31+
"url": "https://github.com/foo"
32+
},
33+
"audit_actions": [
34+
{
35+
"action": "publish",
36+
"user": {
37+
"id": 1,
38+
"login": "foo",
39+
"name": null,
40+
"avatar": null,
41+
"url": "https://github.com/foo"
42+
},
43+
"time": "2024-09-18T14:27:21.355906+00:00"
44+
},
45+
{
46+
"action": "yank",
47+
"user": {
48+
"id": 1,
49+
"login": "foo",
50+
"name": null,
51+
"avatar": null,
52+
"url": "https://github.com/foo"
53+
},
54+
"time": "2024-09-18T14:27:21.932571+00:00"
55+
},
56+
{
57+
"action": "yank",
58+
"user": {
59+
"id": 1,
60+
"login": "foo",
61+
"name": null,
62+
"avatar": null,
63+
"url": "https://github.com/foo"
64+
},
65+
"time": "2024-09-18T14:27:22.292030+00:00"
66+
},
67+
{
68+
"action": "unyank",
69+
"user": {
70+
"id": 1,
71+
"login": "foo",
72+
"name": null,
73+
"avatar": null,
74+
"url": "https://github.com/foo"
75+
},
76+
"time": "2024-09-18T14:27:22.497519+00:00"
77+
}
78+
],
79+
"checksum": "ddfc395ab340f413ee1d1ed0afce51a7c9df1c99c551fed5aef76edd4abe4048",
80+
"rust_version": null,
81+
"has_lib": false,
82+
"bin_names": []
83+
}
84+
}

0 commit comments

Comments
 (0)