Skip to content
This repository has been archived by the owner on Sep 3, 2024. It is now read-only.

Commit

Permalink
Change release tests to be more realistic
Browse files Browse the repository at this point in the history
  • Loading branch information
karol-t-wilk committed Jun 14, 2024
1 parent e077d9a commit f9bf2e9
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions test/search/hex_client_test/release_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f9bf2e9

Please sign in to comment.