Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule Tzdata.Mixfile do
use Mix.Project

@version "1.2.1"
@version "1.2.2"

def project do
[
Expand Down
13 changes: 9 additions & 4 deletions test/data_loader_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)

Expand All @@ -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, "")
Expand Down
Loading