Skip to content

Replace raw compact index wire format with test helpers - #187

Merged
jenshenny merged 1 commit into
js/ca-test-gaps-content-addressfrom
js/ca-compact-index-test-helpers
Aug 27, 2026
Merged

Replace raw compact index wire format with test helpers#187
jenshenny merged 1 commit into
js/ca-test-gaps-content-addressfrom
js/ca-compact-index-test-helpers

Conversation

@jenshenny

@jenshenny jenshenny commented Aug 27, 2026

Copy link
Copy Markdown

Improve compact index test infrastructure for content-addressable gems

Problem

The CA test additions in ruby#9773 set up compact index fixtures by hand-rolling raw wire-format strings — versions lists, info bodies, checksums, and platform:= metadata. This is fragile, verbose, and requires test authors to understand the compact index wire format:

versions_body = +"created_at: 2026-01-01T00:00:00Z\n---\na 1-abcdef12 0000\n"
versions_response = util_compact_index_response(versions_body)
versions_response.uri = Gem::URI("#{@gem_repo}versions")
@fetcher.data["#{@gem_repo}versions"] = versions_response
@fetcher.data["#{@gem_repo}info/a"] = util_compact_index_response("---\n1-abcdef12 |checksum:123,ruby:~> 3.3.0,platform:= x86_64-linux\n")

Solution

Extend the existing util_setup_compact_index / util_compact_index_info_line helpers to generate CA metadata from spec objects, and add a util_ca_spec helper (built on util_spec) for creating content-addressable specs. Tests now read:

spec = util_ca_spec("a", "1", "abcdef12", ruby_abi: "3.3", platform: "x86_64-linux")
util_setup_compact_index(spec)

@jenshenny
jenshenny marked this pull request as ready for review August 27, 2026 20:13
@jenshenny
jenshenny force-pushed the js/ca-compact-index-test-helpers branch 2 times, most recently from e36f77b to c21ac0d Compare August 27, 2026 20:18
@jenshenny
jenshenny force-pushed the js/ca-compact-index-test-helpers branch from c21ac0d to 5d6ec09 Compare August 27, 2026 20:22
@jenshenny
jenshenny requested a balanced review from Copilot August 27, 2026 20:29

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error: Your billing is not configured or you have Copilot licenses from multiple standalone organizations or enterprises. To use premium requests, select a billing entity via the GitHub site, under Settings > Copilot > Features.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.

Comment thread test/rubygems/helper.rb Outdated
Comment on lines +997 to +1001
def util_ca_spec(name, version, content_address, ruby_abi: nil, platform: "x86_64-linux", required_ruby_version: nil, &block)
util_spec(name, version) do |s|
s.platform = Gem::Platform.new(platform)
s.content_address = content_address
s.required_ruby_version = required_ruby_version || (ruby_abi ? "~> #{ruby_abi}.0" : nil)
Comment thread test/rubygems/helper.rb Outdated
@jenshenny
jenshenny force-pushed the js/ca-compact-index-test-helpers branch from 5d6ec09 to 875b8d5 Compare August 27, 2026 20:58
@jenshenny
jenshenny requested a balanced review from Copilot August 27, 2026 21:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.

Comment thread test/rubygems/test_gem_commands_search_command.rb
@jenshenny
jenshenny force-pushed the js/ca-compact-index-test-helpers branch 2 times, most recently from 61193a0 to ec4e87e Compare August 27, 2026 21:21
Extend util_compact_index_info_line to emit CA metadata (version-content_address
string, platform:=) and util_setup_compact_index to use CA version strings in the
versions list. Add util_ca_spec helper (built on util_spec) for creating
content-addressable specs. Refactor 5 test files (28 tests) to use util_ca_spec +
util_setup_compact_index instead of raw wire-format strings. Edge case tests
(empty info body, missing platform metadata, mixed CA+non-CA same name) remain raw.

Also fix multiline operation indentation in ContentAddressableInfo#eql?.

Assisted-By: devx/2658d4ad-be37-4929-8dda-b1d772952c7b
@jenshenny
jenshenny force-pushed the js/ca-compact-index-test-helpers branch from ec4e87e to e0b79ca Compare August 27, 2026 21:22
@jenshenny
jenshenny merged commit a3547fe into feature-branch-ca-changes-rubygems Aug 27, 2026
135 of 137 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants