Skip to content

Commit 9ad4590

Browse files
Copilotlpcox
andauthored
test: strengthen tracing helper coverage
Agent-Logs-Url: https://github.com/github/gh-aw-mcpg/sessions/348fae3e-5b56-42bd-bd42-c82af76c53b5 Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
1 parent 918b6b0 commit 9ad4590

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ require (
1212
require (
1313
github.com/itchyny/gojq v0.12.19
1414
github.com/santhosh-tekuri/jsonschema/v5 v5.3.1
15+
github.com/spf13/pflag v1.0.9
1516
github.com/stretchr/testify v1.11.1
1617
github.com/tetratelabs/wazero v1.11.0
1718
go.opentelemetry.io/otel v1.43.0
@@ -34,7 +35,6 @@ require (
3435
github.com/pmezard/go-difflib v1.0.0 // indirect
3536
github.com/segmentio/asm v1.1.3 // indirect
3637
github.com/segmentio/encoding v0.5.4 // indirect
37-
github.com/spf13/pflag v1.0.9 // indirect
3838
github.com/yosida95/uritemplate/v3 v3.0.2 // indirect
3939
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
4040
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.43.0 // indirect

internal/cmd/tracing_helpers_test.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"github.com/github/gh-aw-mcpg/internal/config"
1111
)
1212

13-
func TestRegisterTracingFlags_DefaultsFromEnvAndConfig(t *testing.T) {
13+
func TestRegisterTracingFlags_DefaultsFromEnv(t *testing.T) {
1414
t.Setenv("OTEL_EXPORTER_OTLP_ENDPOINT", "http://collector:4318")
1515
t.Setenv("OTEL_SERVICE_NAME", "test-service")
1616

@@ -41,4 +41,14 @@ func TestRegisterTracingFlags_DefaultsFromEnvAndConfig(t *testing.T) {
4141
actualSampleRate, err := cmd.Flags().GetFloat64("otlp-sample-rate")
4242
require.NoError(t, err)
4343
assert.Equal(t, config.DefaultTracingSampleRate, actualSampleRate)
44+
45+
err = cmd.ParseFlags([]string{
46+
"--otlp-endpoint=http://override:4318",
47+
"--otlp-service-name=override-service",
48+
"--otlp-sample-rate=0.25",
49+
})
50+
require.NoError(t, err)
51+
assert.Equal(t, "http://override:4318", endpoint)
52+
assert.Equal(t, "override-service", service)
53+
assert.Equal(t, 0.25, sampleRate)
4454
}

0 commit comments

Comments
 (0)