diff --git a/CHANGELOG.md b/CHANGELOG.md index 27a7be8..8e4ea5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,11 +2,15 @@ ## [Unreleased] +## [1.2.2] - 2026-09-25 + ### Fixed - Fix a pattern match bug in `latest_file_size/1` that caused the HEAD request used to check the latest tzdata file size to always fail, silently falling back to a GET request instead. (Matt Wynne) +- Fix a compile warning about an unused `require Logger` when Hackney + isn't available. (Michel Boaventura) ## [1.2.1] - 2026-09-15 diff --git a/mix.exs b/mix.exs index 514236e..46d3e79 100644 --- a/mix.exs +++ b/mix.exs @@ -1,7 +1,7 @@ defmodule Tzdata.Mixfile do use Mix.Project - @version "1.2.1" + @version "1.2.2" def project do [ diff --git a/test/data_loader_test.exs b/test/data_loader_test.exs index 3b11de2..c27d33d 100644 --- a/test/data_loader_test.exs +++ b/test/data_loader_test.exs @@ -26,7 +26,12 @@ if Code.ensure_loaded?(Sham) do test "gets file size from HEAD request", %{sham: sham} do url = "http://localhost:#{sham.port}/test.tar.gz" - Sham.expect(sham, "HEAD", "/test.tar.gz", fn conn -> + # `stub` rather than `expect`: `expect`'s "was this called" check + # races the client receiving the response against the plug's + # (separate, later) bookkeeping call recording that fact, which + # is occasionally still pending when this test's on_exit runs. + # The assertion below already fully verifies the request happened. + Sham.stub(sham, "HEAD", "/test.tar.gz", fn conn -> # For HEAD requests, include a body matching the content-length # (in reality, HEAD responses don't include the body, but for testing # with Sham, Plug will calculate content-length from the body) @@ -42,11 +47,11 @@ if Code.ensure_loaded?(Sham) do test "falls back to GET when HEAD fails", %{sham: sham} do url = "http://localhost:#{sham.port}/fallback.tar.gz" - Sham.expect(sham, "HEAD", "/fallback.tar.gz", fn conn -> + Sham.stub(sham, "HEAD", "/fallback.tar.gz", fn conn -> Plug.Conn.resp(conn, 404, "") end) - Sham.expect(sham, "GET", "/fallback.tar.gz", fn conn -> + Sham.stub(sham, "GET", "/fallback.tar.gz", fn conn -> Plug.Conn.resp(conn, 200, "test body content") end) @@ -58,7 +63,7 @@ if Code.ensure_loaded?(Sham) do test "gets last modified date from HEAD request", %{sham: sham} do url = "http://localhost:#{sham.port}/modified.tar.gz" - Sham.expect(sham, "HEAD", "/modified.tar.gz", fn conn -> + Sham.stub(sham, "HEAD", "/modified.tar.gz", fn conn -> conn |> Plug.Conn.put_resp_header("last-modified", "Wed, 21 Oct 2015 07:28:00 GMT") |> Plug.Conn.send_resp(200, "")