mirror of
https://github.com/anthonyoteri/dredge.git
synced 2026-06-05 15:26:53 -04:00
Merge pull request #49 from anthonyoteri/replace-async-std-with-tokio
Use better async runtime
This commit is contained in:
+2
-2
@@ -21,7 +21,6 @@ categories = [
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
async-std = { version = "1.12.0", features = ["async-attributes", "attributes", "tokio1"] }
|
||||
clap = { version = "4.4.3", features = ["derive", "env", "wrap_help"] }
|
||||
simple_logger = { version = "4.2.0", features = ["timestamps", "colors", "stderr"] }
|
||||
http = "0.2.9"
|
||||
@@ -35,7 +34,8 @@ thiserror = "1.0.48"
|
||||
toml = "0.8.0"
|
||||
url = { version = "2.4.1", features = ["serde"] }
|
||||
xdg = "2.5.2"
|
||||
tokio = { version = "1.32.0", features = ["macros"] }
|
||||
|
||||
[dev-dependencies]
|
||||
mockito = "1.2.0"
|
||||
env_logger = "0.10.0"
|
||||
env_logger = "0.10.0"
|
||||
|
||||
+3
-3
@@ -207,7 +207,7 @@ mod tests {
|
||||
///
|
||||
/// Attempt to parse a valid RFC5988 header value, and ensure that the
|
||||
/// parsed URL was returned as expected.
|
||||
#[async_std::test]
|
||||
#[tokio::test]
|
||||
async fn test_parse_rfc5988_valid() {
|
||||
// Mock a valid RFC5988 header value
|
||||
let valid_header_value =
|
||||
@@ -225,7 +225,7 @@ mod tests {
|
||||
///
|
||||
/// Attempt to parse an invalid string as RFC5988, ensuring that the `None`
|
||||
/// variant is returned.
|
||||
#[async_std::test]
|
||||
#[tokio::test]
|
||||
async fn test_parse_rfc5988_invalid() {
|
||||
// Mock a valid RFC5988 header value
|
||||
let invalid_header_value = HeaderValue::from_str(r#"invalid header value"#)
|
||||
@@ -244,7 +244,7 @@ mod tests {
|
||||
/// the digest with the proper headers set. The test then validates that
|
||||
/// the correct digest is returned and that the mock server had the expected
|
||||
/// interactions.
|
||||
#[async_std::test]
|
||||
#[tokio::test]
|
||||
async fn test_get_digest() -> Result<(), ApiError> {
|
||||
let mut server = mockito::Server::new_async().await;
|
||||
let path = "/v2/foo/manifests/latest";
|
||||
|
||||
+8
-8
@@ -224,7 +224,7 @@ mod tests {
|
||||
/// This test spins up a mock server, and makes a request to the catalog
|
||||
/// endpoint. It checks that the handler both called the request the
|
||||
/// expected number of times, and did not return an error.
|
||||
#[async_std::test]
|
||||
#[tokio::test]
|
||||
async fn test_catalog_handler() {
|
||||
let mut server = mockito::Server::new_async().await;
|
||||
let path = "/v2/_catalog";
|
||||
@@ -253,7 +253,7 @@ mod tests {
|
||||
/// should follow, resulting in the combined list. It checks that the
|
||||
/// handler both called the request the expected number of times, and did
|
||||
/// not return an error.
|
||||
#[async_std::test]
|
||||
#[tokio::test]
|
||||
async fn test_catalog_handler_with_pagination() {
|
||||
let mut server = mockito::Server::new_async().await;
|
||||
let path = "/v2/_catalog";
|
||||
@@ -294,7 +294,7 @@ mod tests {
|
||||
/// This test spins up a mock server, and makes a request to the tags
|
||||
/// endpoint. It checks that the handler both called the request the
|
||||
/// expected number of times, and did not return an error.
|
||||
#[async_std::test]
|
||||
#[tokio::test]
|
||||
async fn test_tags_handler() {
|
||||
let mut server = mockito::Server::new_async().await;
|
||||
let path = "/v2/some_image/tags/list";
|
||||
@@ -324,7 +324,7 @@ mod tests {
|
||||
/// should follow, resulting in the combined list. It checks that the
|
||||
/// handler both called the request the expected number of times, and did
|
||||
/// not return an error.
|
||||
#[async_std::test]
|
||||
#[tokio::test]
|
||||
async fn test_tags_handler_with_pagination() {
|
||||
let mut server = mockito::Server::new_async().await;
|
||||
let path = "/v2/some_image/tags/list";
|
||||
@@ -366,7 +366,7 @@ mod tests {
|
||||
/// This test spins up a mock server, and makes a request to the check
|
||||
/// endpoint. It checks that the handler both called the request the
|
||||
/// expected number of times, and did not return an error.
|
||||
#[async_std::test]
|
||||
#[tokio::test]
|
||||
async fn test_check_handler() {
|
||||
let mut server = mockito::Server::new_async().await;
|
||||
let path = "/v2";
|
||||
@@ -392,7 +392,7 @@ mod tests {
|
||||
///
|
||||
/// This validates that if the "Docker-Distribution-API-Version" header
|
||||
/// is missing in the response, the appropriate error is returned.
|
||||
#[async_std::test]
|
||||
#[tokio::test]
|
||||
async fn test_check_handler_missing_api_version() -> Result<(), Box<dyn Error>> {
|
||||
let mut server = mockito::Server::new_async().await;
|
||||
let path = "/v2";
|
||||
@@ -425,7 +425,7 @@ mod tests {
|
||||
/// This validates that if the "Docker-Distribution-API-Version" header
|
||||
/// is present in the response but contains an unexpected value, the
|
||||
/// appropriate error is returned.
|
||||
#[async_std::test]
|
||||
#[tokio::test]
|
||||
async fn test_check_handler_invalid_api_version() -> Result<(), Box<dyn Error>> {
|
||||
let mut server = mockito::Server::new_async().await;
|
||||
let path = "/v2";
|
||||
@@ -459,7 +459,7 @@ mod tests {
|
||||
/// This test spins up a mock server, and makes a request to the image
|
||||
/// manifests endpoint. It checks that the handler both called the request
|
||||
/// the expected number of times, and did not return an error.
|
||||
#[async_std::test]
|
||||
#[tokio::test]
|
||||
async fn test_show_handler() {
|
||||
let mut server = mockito::Server::new_async().await;
|
||||
let path = "/v2/foo/manifests/latest";
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ fn parse_registry_arg(host: &str) -> Result<Url, DredgeError> {
|
||||
Url::parse(&host).or(Err(DredgeError::RegistryUrlError(host.to_string())))
|
||||
}
|
||||
|
||||
#[async_std::main]
|
||||
#[tokio::main(flavor = "current_thread")]
|
||||
async fn main() -> Result<(), DredgeError> {
|
||||
let args = Cli::parse();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user