From f9bf2e92442197cd55a3941e986e0a6bf6b867a8 Mon Sep 17 00:00:00 2001 From: Karol Wilk Date: Fri, 14 Jun 2024 12:53:26 +0200 Subject: [PATCH] Change release tests to be more realistic --- test/search/hex_client_test/release_test.exs | 27 +++++++++----------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/test/search/hex_client_test/release_test.exs b/test/search/hex_client_test/release_test.exs index 05c9c6e..bd5f7c2 100644 --- a/test/search/hex_client_test/release_test.exs +++ b/test/search/hex_client_test/release_test.exs @@ -6,35 +6,32 @@ defmodule Search.HexClientTest.ReleaseTest do describe "latest/1" do test "when given no prerelease entries, returns the release with largest version" do releases = [ - %Release{package_name: "lesser", version: Version.parse!("1.2.3")}, - %Release{package_name: "greater", version: Version.parse!("2.1.3")}, - %Release{package_name: "middle", version: Version.parse!("1.4.3")} + %Release{version: Version.parse!("1.2.3")}, + %Release{version: Version.parse!("2.1.3")}, + %Release{version: Version.parse!("1.4.3")} ] - assert %Release{package_name: "greater"} = - Release.latest(releases) + assert Release.latest(releases).version == Version.parse!("2.1.3") end test "when given only prerelease entries, returns the prerelease with largest version" do releases = [ - %Release{package_name: "lesser", version: Version.parse!("1.2.3-rc1")}, - %Release{package_name: "greater", version: Version.parse!("2.1.3-rc2")}, - %Release{package_name: "middle", version: Version.parse!("1.4.3-rc1")} + %Release{version: Version.parse!("1.2.3-rc1")}, + %Release{version: Version.parse!("2.1.3-rc2")}, + %Release{version: Version.parse!("1.4.3-rc1")} ] - assert %Release{package_name: "greater"} = - Release.latest(releases) + assert Release.latest(releases).version == Version.parse!("2.1.3-rc2") end test "when given mixed release and prerelease entries, returns the release with largest version" do releases = [ - %Release{package_name: "lesser", version: Version.parse!("1.2.3")}, - %Release{package_name: "greater", version: Version.parse!("2.1.3")}, - %Release{package_name: "prerelease", version: Version.parse!("4.4.3-rc1")} + %Release{version: Version.parse!("1.2.3")}, + %Release{version: Version.parse!("2.1.3")}, + %Release{version: Version.parse!("4.4.3-rc1")} ] - assert %Release{package_name: "greater"} = - Release.latest(releases) + assert Release.latest(releases).version == Version.parse!("2.1.3") end test "when given an empty list, returns nil" do