From 321779758ffe448217adcae38b700851149f8210 Mon Sep 17 00:00:00 2001 From: Martin Becze Date: Mon, 16 Nov 2020 01:13:00 -0600 Subject: [PATCH 7/7] test: Update tests to cover semver. * tests/crate.scm (cargo-recursive-import): Update the tests to so that the recusive import tests cover using semver. --- tests/crate.scm | 147 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 102 insertions(+), 45 deletions(-) diff --git a/tests/crate.scm b/tests/crate.scm index 68481d9932..3c0fb26fcd 100644 --- a/tests/crate.scm +++ b/tests/crate.scm @@ -88,14 +88,14 @@ "{ \"dependencies\": [ { - \"crate_id\": \"intermediate-1\", + \"crate_id\": \"intermediate-a\", \"kind\": \"normal\", - \"req\": \"1.0.0\" + \"req\": \"^1.0.0\" }, { - \"crate_id\": \"intermediate-2\", + \"crate_id\": \"intermediate-b\", \"kind\": \"normal\", - \"req\": \"1.0.0\" + \"req\": \"*.0.0\" } { \"crate_id\": \"leaf-alice\", @@ -110,33 +110,46 @@ ] }") -(define test-intermediate-1-crate +(define test-intermediate-a-crate "{ \"crate\": { - \"max_version\": \"1.0.0\", - \"name\": \"intermediate-1\", + \"max_version\": \"1.0.1\", + \"name\": \"intermediate-a\", \"description\": \"summary\", \"homepage\": \"http://example.com\", \"repository\": \"http://example.com\", \"keywords\": [\"dummy\", \"test\"], \"categories\": [\"test\"], \"actual_versions\": [ - { \"id\": \"intermediate-1\", + { \"id\": \"intermediate-a\", + \"num\": \"2.0.0\", + \"license\": \"MIT OR Apache-2.0\", + \"links\": { + \"dependencies\": \"/api/v1/crates/intermediate-a/1.0.1/dependencies\" + } + } + { \"id\": \"intermediate-a\", + \"num\": \"1.0.1\", + \"license\": \"MIT OR Apache-2.0\", + \"links\": { + \"dependencies\": \"/api/v1/crates/intermediate-a/1.0.1/dependencies\" + } + },{ \"id\": \"intermediate-a\", \"num\": \"1.0.0\", \"license\": \"MIT OR Apache-2.0\", \"links\": { - \"dependencies\": \"/api/v1/crates/intermediate-1/1.0.0/dependencies\" + \"dependencies\": \"/api/v1/crates/intermediate-a/1.0.1/dependencies\" } } ] } }") -(define test-intermediate-1-dependencies +(define test-intermediate-a-dependencies "{ \"dependencies\": [ { - \"crate_id\": \"intermediate-2\", + \"crate_id\": \"intermediate-b\", \"kind\": \"normal\", \"req\": \"1.0.0\" }, @@ -153,29 +166,36 @@ ] }") -(define test-intermediate-2-crate +(define test-intermediate-b-crate "{ \"crate\": { \"max_version\": \"1.0.0\", - \"name\": \"intermediate-2\", + \"name\": \"intermediate-b\", \"description\": \"summary\", \"homepage\": \"http://example.com\", \"repository\": \"http://example.com\", \"keywords\": [\"dummy\", \"test\"], \"categories\": [\"test\"], \"actual_versions\": [ - { \"id\": \"intermediate-2\", + { \"id\": \"intermediate-b\", + \"num\": \"2.0.0\", + \"license\": \"MIT OR Apache-2.0\", + \"links\": { + \"dependencies\": \"/api/v1/crates/intermediate-b/2.0.0/dependencies\" + } + }, + { \"id\": \"intermediate-b\", \"num\": \"1.0.0\", \"license\": \"MIT OR Apache-2.0\", \"links\": { - \"dependencies\": \"/api/v1/crates/intermediate-2/1.0.0/dependencies\" + \"dependencies\": \"/api/v1/crates/intermediate-b/1.0.0/dependencies\" } } ] } }") -(define test-intermediate-2-dependencies +(define test-intermediate-b-dependencies "{ \"dependencies\": [ { @@ -230,6 +250,13 @@ \"links\": { \"dependencies\": \"/api/v1/crates/leaf-bob/1.0.0/dependencies\" } + }, + { \"id\": \"leaf-bob\", + \"num\": \"0.1.0\", + \"license\": \"MIT OR Apache-2.0\", + \"links\": { + \"dependencies\": \"/api/v1/crates/leaf-bob/0.1.0/dependencies\" + } } ] } @@ -320,24 +347,31 @@ (open-input-string "empty file\n")) ("https://crates.io/api/v1/crates/root/1.0.0/dependencies" (open-input-string test-root-dependencies)) - ("https://crates.io/api/v1/crates/intermediate-1" - (open-input-string test-intermediate-1-crate)) - ("https://crates.io/api/v1/crates/intermediate-1/1.0.0/download" + ("https://crates.io/api/v1/crates/intermediate-a" + (open-input-string test-intermediate-a-crate)) + ("https://crates.io/api/v1/crates/intermediate-a/1.0.1/download" + (set! test-source-hash + (bytevector->nix-base32-string + (sha256 (string->bytevector "empty file\n" "utf-8")))) + (open-input-string "empty file\n")) + ("https://crates.io/api/v1/crates/intermediate-a/1.0.1/dependencies" + (open-input-string test-intermediate-a-dependencies)) + ("https://crates.io/api/v1/crates/intermediate-b" + (open-input-string test-intermediate-b-crate)) + ("https://crates.io/api/v1/crates/intermediate-b/1.0.0/download" (set! test-source-hash (bytevector->nix-base32-string (sha256 (string->bytevector "empty file\n" "utf-8")))) (open-input-string "empty file\n")) - ("https://crates.io/api/v1/crates/intermediate-1/1.0.0/dependencies" - (open-input-string test-intermediate-1-dependencies)) - ("https://crates.io/api/v1/crates/intermediate-2" - (open-input-string test-intermediate-2-crate)) - ("https://crates.io/api/v1/crates/intermediate-2/1.0.0/download" + ("https://crates.io/api/v1/crates/intermediate-b/2.0.0/download" (set! test-source-hash (bytevector->nix-base32-string (sha256 (string->bytevector "empty file\n" "utf-8")))) (open-input-string "empty file\n")) - ("https://crates.io/api/v1/crates/intermediate-2/1.0.0/dependencies" - (open-input-string test-intermediate-2-dependencies)) + ("https://crates.io/api/v1/crates/intermediate-b/1.0.0/dependencies" + (open-input-string test-intermediate-b-dependencies)) + ("https://crates.io/api/v1/crates/intermediate-b/2.0.0/dependencies" + (open-input-string test-intermediate-b-dependencies)) ("https://crates.io/api/v1/crates/leaf-alice" (open-input-string test-leaf-alice-crate)) ("https://crates.io/api/v1/crates/leaf-alice/1.0.0/download" @@ -358,11 +392,34 @@ (open-input-string test-leaf-bob-dependencies)) (_ (error "Unexpected URL: " url))))) (match (crate-recursive-import "root") - ;; rust-intermediate-2 has no dependency on the rust-leaf-alice package, so this is a valid ordering - (((define-public rust-leaf-alice-1.0 + ;; rust-intermediate-B has no dependency on the rust-leaf-alice package, so this is a valid ordering + (((define-public rust-intermediate-b-2.0 + (package + (name "rust-intermediate-b") + (version "2.0.0") + (source + (origin + (method url-fetch) + (uri (crate-uri "intermediate-b" version)) + (file-name + (string-append name "-" version ".tar.gz")) + (sha256 + (base32 + (? string? hash))))) + (build-system cargo-build-system) + (arguments + ('quasiquote (#:skip-build? #t + #:cargo-inputs + (("rust-leaf-bob" + ('unquote rust-leaf-bob-1.0)))))) + (home-page "http://example.com") + (synopsis "summary") + (description "summary") + (license (list license:expat license:asl2.0)))) + (define-public rust-leaf-alice-1.0 (package (name "rust-leaf-alice") - (version (? string? ver)) + (version "1.0.0") (source (origin (method url-fetch) @@ -381,7 +438,7 @@ (define-public rust-leaf-bob-1.0 (package (name "rust-leaf-bob") - (version (? string? ver)) + (version "1.0.0") (source (origin (method url-fetch) @@ -397,14 +454,14 @@ (synopsis "summary") (description "summary") (license (list license:expat license:asl2.0)))) - (define-public rust-intermediate-2-1.0 + (define-public rust-intermediate-b-1.0 (package - (name "rust-intermediate-2") - (version (? string? ver)) + (name "rust-intermediate-b") + (version "1.0.0") (source (origin (method url-fetch) - (uri (crate-uri "intermediate-2" version)) + (uri (crate-uri "intermediate-b" version)) (file-name (string-append name "-" version ".tar.gz")) (sha256 @@ -420,14 +477,14 @@ (synopsis "summary") (description "summary") (license (list license:expat license:asl2.0)))) - (define-public rust-intermediate-1-1.0 + (define-public rust-intermediate-a-1.0 (package - (name "rust-intermediate-1") - (version (? string? ver)) + (name "rust-intermediate-a") + (version "1.0.1") (source (origin (method url-fetch) - (uri (crate-uri "intermediate-1" version)) + (uri (crate-uri "intermediate-a" version)) (file-name (string-append name "-" version ".tar.gz")) (sha256 @@ -437,8 +494,8 @@ (arguments ('quasiquote (#:skip-build? #t #:cargo-inputs - (("rust-intermediate-2" - ,rust-intermediate-2-1.0) + (("rust-intermediate-b" + ,rust-intermediate-b-1.0) ("rust-leaf-alice" ('unquote rust-leaf-alice-1.0)) ("rust-leaf-bob" @@ -450,7 +507,7 @@ (define-public rust-root-1.0 (package (name "rust-root") - (version (? string? ver)) + (version "1.0.0") (source (origin (method url-fetch) @@ -463,10 +520,10 @@ (build-system cargo-build-system) (arguments ('quasiquote (#:cargo-inputs - (("rust-intermediate-1" - ('unquote rust-intermediate-1-1.0)) - ("rust-intermediate-2" - ('unquote rust-intermediate-2-1.0)) + (("rust-intermediate-a" + ('unquote rust-intermediate-a-1.0)) + ("rust-intermediate-b" + ('unquote rust-intermediate-b-2.0)) ("rust-leaf-alice" ('unquote rust-leaf-alice-1.0)) ("rust-leaf-bob" -- 2.29.2