Skip to content

fix: use keyed fields in SamplePair struct literals in api_test.go#2012

Open
immanuwell wants to merge 1 commit into
prometheus:mainfrom
immanuwell:fix/unkeyed-samplepair-struct-literals
Open

fix: use keyed fields in SamplePair struct literals in api_test.go#2012
immanuwell wants to merge 1 commit into
prometheus:mainfrom
immanuwell:fix/unkeyed-samplepair-struct-literals

Conversation

@immanuwell
Copy link
Copy Markdown
Contributor

go vet ./... fails on 15 unkeyed model.SamplePair struct literals in TestSamplesJSONSerialization. The bench test in the same package already uses keyed syntax, so this just brings api_test.go in line with it.

Reproduce:

go vet ./api/prometheus/v1/...
# api/prometheus/v1 [api/prometheus/v1.test]
api/prometheus/v1/api_test.go:1622:14: github.com/prometheus/common/model.SamplePair struct literal uses unkeyed fields
...

Fix: add Timestamp: and Value: field names to all 15 literals. No behavior change, tests still pass.

@bwplotka @beorn7

Signed-off-by: Immanuel Tikhonov <pchpr.00@list.ru>
Signed-off-by: immanuwell <pchpr.00@list.ru>
@immanuwell immanuwell force-pushed the fix/unkeyed-samplepair-struct-literals branch from a8b319f to b65f296 Compare May 30, 2026 08:57
@kakkoyun
Copy link
Copy Markdown
Member

kakkoyun commented Jun 1, 2026

LGTM. However, mac os tests are failing. We need to check.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates TestSamplesJSONSerialization to use keyed field names (Timestamp: and Value:) in model.SamplePair struct literals, aligning the test with go vet expectations and existing usage patterns in the package.

Changes:

  • Replaced 15 unkeyed model.SamplePair{...} literals with keyed equivalents to satisfy go vet ./....
  • Kept test semantics unchanged (same timestamp/value inputs and expected JSON output).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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