Skip to content

Commit

Permalink
[golden] use testing.TB as argument (#30277)
Browse files Browse the repository at this point in the history
  • Loading branch information
atoulme committed Jan 4, 2024
1 parent 1d4b064 commit e3702b0
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
27 changes: 27 additions & 0 deletions .chloggen/use_testing_tb_golden.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: breaking

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: golden

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Use testing.TB for golden.WriteMetrics, golden.WriteTraces and golden.WriteLogs over *testing.T

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [30277]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: [api]
6 changes: 3 additions & 3 deletions pkg/golden/golden.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func ReadMetrics(filePath string) (pmetric.Metrics, error) {
}

// WriteMetrics writes a pmetric.Metrics to the specified file in YAML format.
func WriteMetrics(t *testing.T, filePath string, metrics pmetric.Metrics) error {
func WriteMetrics(t testing.TB, filePath string, metrics pmetric.Metrics) error {
if err := writeMetrics(filePath, metrics); err != nil {
return err
}
Expand Down Expand Up @@ -99,7 +99,7 @@ func ReadLogs(filePath string) (plog.Logs, error) {
}

// WriteLogs writes a plog.Logs to the specified file in YAML format.
func WriteLogs(t *testing.T, filePath string, logs plog.Logs) error {
func WriteLogs(t testing.TB, filePath string, logs plog.Logs) error {
if err := writeLogs(filePath, logs); err != nil {
return err
}
Expand Down Expand Up @@ -150,7 +150,7 @@ func ReadTraces(filePath string) (ptrace.Traces, error) {
}

// WriteTraces writes a ptrace.Traces to the specified file in YAML format.
func WriteTraces(t *testing.T, filePath string, traces ptrace.Traces) error {
func WriteTraces(t testing.TB, filePath string, traces ptrace.Traces) error {
if err := writeTraces(filePath, traces); err != nil {
return err
}
Expand Down

0 comments on commit e3702b0

Please sign in to comment.