Skip to content

Commit

Permalink
Add unit tests for the patch API
Browse files Browse the repository at this point in the history
Signed-off-by: Rustin170506 <[email protected]>
  • Loading branch information
Rustin170506 committed Sep 18, 2024
1 parent a1c4691 commit 1a9722c
Show file tree
Hide file tree
Showing 10 changed files with 542 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/tests/all.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub struct CrateResponse {
versions: Option<Vec<EncodableVersion>>,
keywords: Option<Vec<EncodableKeyword>>,
}
#[derive(Deserialize)]
#[derive(Serialize, Deserialize)]
pub struct VersionResponse {
version: EncodableVersion,
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
source: src/tests/krate/yanking.rs
expression: json
---
{
"version": {
"id": 1,
"crate": "patchable",
"num": "1.0.0",
"dl_path": "/api/v1/crates/patchable/1.0.0/download",
"readme_path": "/api/v1/crates/patchable/1.0.0/readme",
"updated_at": "2024-09-18T14:27:21.928149+00:00",
"created_at": "2024-09-18T14:27:21.355906+00:00",
"downloads": 0,
"features": {},
"yanked": true,
"yank_message": "Yanking reason",
"lib_links": null,
"license": "MIT",
"links": {
"dependencies": "/api/v1/crates/patchable/1.0.0/dependencies",
"version_downloads": "/api/v1/crates/patchable/1.0.0/downloads",
"authors": "/api/v1/crates/patchable/1.0.0/authors"
},
"crate_size": 151,
"published_by": {
"id": 1,
"login": "foo",
"name": null,
"avatar": null,
"url": "https://github.com/foo"
},
"audit_actions": [
{
"action": "publish",
"user": {
"id": 1,
"login": "foo",
"name": null,
"avatar": null,
"url": "https://github.com/foo"
},
"time": "2024-09-18T14:27:21.355906+00:00"
},
{
"action": "yank",
"user": {
"id": 1,
"login": "foo",
"name": null,
"avatar": null,
"url": "https://github.com/foo"
},
"time": "2024-09-18T14:27:21.932571+00:00"
}
],
"checksum": "ddfc395ab340f413ee1d1ed0afce51a7c9df1c99c551fed5aef76edd4abe4048",
"rust_version": null,
"has_lib": false,
"bin_names": []
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
source: src/tests/krate/yanking.rs
expression: response
---
{
"version": {
"id": 1,
"crate": "patchable",
"num": "1.0.0",
"dl_path": "/api/v1/crates/patchable/1.0.0/download",
"readme_path": "/api/v1/crates/patchable/1.0.0/readme",
"updated_at": "2024-09-18T14:27:21.928149+00:00",
"created_at": "2024-09-18T14:27:21.355906+00:00",
"downloads": 0,
"features": {},
"yanked": true,
"yank_message": "Updated reason",
"lib_links": null,
"license": "MIT",
"links": {
"dependencies": "/api/v1/crates/patchable/1.0.0/dependencies",
"version_downloads": "/api/v1/crates/patchable/1.0.0/downloads",
"authors": "/api/v1/crates/patchable/1.0.0/authors"
},
"crate_size": 151,
"published_by": {
"id": 1,
"login": "foo",
"name": null,
"avatar": null,
"url": "https://github.com/foo"
},
"audit_actions": [
{
"action": "publish",
"user": {
"id": 1,
"login": "foo",
"name": null,
"avatar": null,
"url": "https://github.com/foo"
},
"time": "2024-09-18T14:27:21.355906+00:00"
},
{
"action": "yank",
"user": {
"id": 1,
"login": "foo",
"name": null,
"avatar": null,
"url": "https://github.com/foo"
},
"time": "2024-09-18T14:27:21.932571+00:00"
},
{
"action": "yank",
"user": {
"id": 1,
"login": "foo",
"name": null,
"avatar": null,
"url": "https://github.com/foo"
},
"time": "2024-09-18T14:27:22.292030+00:00"
}
],
"checksum": "ddfc395ab340f413ee1d1ed0afce51a7c9df1c99c551fed5aef76edd4abe4048",
"rust_version": null,
"has_lib": false,
"bin_names": []
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
source: src/tests/krate/yanking.rs
expression: json
---
{
"version": {
"id": 1,
"crate": "patchable",
"num": "1.0.0",
"dl_path": "/api/v1/crates/patchable/1.0.0/download",
"readme_path": "/api/v1/crates/patchable/1.0.0/readme",
"updated_at": "2024-09-18T14:27:22.286252+00:00",
"created_at": "2024-09-18T14:27:21.355906+00:00",
"downloads": 0,
"features": {},
"yanked": true,
"yank_message": "Updated reason",
"lib_links": null,
"license": "MIT",
"links": {
"dependencies": "/api/v1/crates/patchable/1.0.0/dependencies",
"version_downloads": "/api/v1/crates/patchable/1.0.0/downloads",
"authors": "/api/v1/crates/patchable/1.0.0/authors"
},
"crate_size": 151,
"published_by": {
"id": 1,
"login": "foo",
"name": null,
"avatar": null,
"url": "https://github.com/foo"
},
"audit_actions": [
{
"action": "publish",
"user": {
"id": 1,
"login": "foo",
"name": null,
"avatar": null,
"url": "https://github.com/foo"
},
"time": "2024-09-18T14:27:21.355906+00:00"
},
{
"action": "yank",
"user": {
"id": 1,
"login": "foo",
"name": null,
"avatar": null,
"url": "https://github.com/foo"
},
"time": "2024-09-18T14:27:21.932571+00:00"
},
{
"action": "yank",
"user": {
"id": 1,
"login": "foo",
"name": null,
"avatar": null,
"url": "https://github.com/foo"
},
"time": "2024-09-18T14:27:22.292030+00:00"
}
],
"checksum": "ddfc395ab340f413ee1d1ed0afce51a7c9df1c99c551fed5aef76edd4abe4048",
"rust_version": null,
"has_lib": false,
"bin_names": []
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---
source: src/tests/krate/yanking.rs
expression: response
---
{
"version": {
"id": 1,
"crate": "patchable",
"num": "1.0.0",
"dl_path": "/api/v1/crates/patchable/1.0.0/download",
"readme_path": "/api/v1/crates/patchable/1.0.0/readme",
"updated_at": "2024-09-18T14:27:22.286252+00:00",
"created_at": "2024-09-18T14:27:21.355906+00:00",
"downloads": 0,
"features": {},
"yanked": false,
"yank_message": null,
"lib_links": null,
"license": "MIT",
"links": {
"dependencies": "/api/v1/crates/patchable/1.0.0/dependencies",
"version_downloads": "/api/v1/crates/patchable/1.0.0/downloads",
"authors": "/api/v1/crates/patchable/1.0.0/authors"
},
"crate_size": 151,
"published_by": {
"id": 1,
"login": "foo",
"name": null,
"avatar": null,
"url": "https://github.com/foo"
},
"audit_actions": [
{
"action": "publish",
"user": {
"id": 1,
"login": "foo",
"name": null,
"avatar": null,
"url": "https://github.com/foo"
},
"time": "2024-09-18T14:27:21.355906+00:00"
},
{
"action": "yank",
"user": {
"id": 1,
"login": "foo",
"name": null,
"avatar": null,
"url": "https://github.com/foo"
},
"time": "2024-09-18T14:27:21.932571+00:00"
},
{
"action": "yank",
"user": {
"id": 1,
"login": "foo",
"name": null,
"avatar": null,
"url": "https://github.com/foo"
},
"time": "2024-09-18T14:27:22.292030+00:00"
},
{
"action": "unyank",
"user": {
"id": 1,
"login": "foo",
"name": null,
"avatar": null,
"url": "https://github.com/foo"
},
"time": "2024-09-18T14:27:22.497519+00:00"
}
],
"checksum": "ddfc395ab340f413ee1d1ed0afce51a7c9df1c99c551fed5aef76edd4abe4048",
"rust_version": null,
"has_lib": false,
"bin_names": []
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---
source: src/tests/krate/yanking.rs
expression: json
---
{
"version": {
"id": 1,
"crate": "patchable",
"num": "1.0.0",
"dl_path": "/api/v1/crates/patchable/1.0.0/download",
"readme_path": "/api/v1/crates/patchable/1.0.0/readme",
"updated_at": "2024-09-18T14:27:22.494398+00:00",
"created_at": "2024-09-18T14:27:21.355906+00:00",
"downloads": 0,
"features": {},
"yanked": false,
"yank_message": null,
"lib_links": null,
"license": "MIT",
"links": {
"dependencies": "/api/v1/crates/patchable/1.0.0/dependencies",
"version_downloads": "/api/v1/crates/patchable/1.0.0/downloads",
"authors": "/api/v1/crates/patchable/1.0.0/authors"
},
"crate_size": 151,
"published_by": {
"id": 1,
"login": "foo",
"name": null,
"avatar": null,
"url": "https://github.com/foo"
},
"audit_actions": [
{
"action": "publish",
"user": {
"id": 1,
"login": "foo",
"name": null,
"avatar": null,
"url": "https://github.com/foo"
},
"time": "2024-09-18T14:27:21.355906+00:00"
},
{
"action": "yank",
"user": {
"id": 1,
"login": "foo",
"name": null,
"avatar": null,
"url": "https://github.com/foo"
},
"time": "2024-09-18T14:27:21.932571+00:00"
},
{
"action": "yank",
"user": {
"id": 1,
"login": "foo",
"name": null,
"avatar": null,
"url": "https://github.com/foo"
},
"time": "2024-09-18T14:27:22.292030+00:00"
},
{
"action": "unyank",
"user": {
"id": 1,
"login": "foo",
"name": null,
"avatar": null,
"url": "https://github.com/foo"
},
"time": "2024-09-18T14:27:22.497519+00:00"
}
],
"checksum": "ddfc395ab340f413ee1d1ed0afce51a7c9df1c99c551fed5aef76edd4abe4048",
"rust_version": null,
"has_lib": false,
"bin_names": []
}
}
Loading

0 comments on commit 1a9722c

Please sign in to comment.