Skip to content

Commit

Permalink
[internal/aws/proxy] Fix proxy server unit test (amazon-contributing#177
Browse files Browse the repository at this point in the history
)
  • Loading branch information
jefchien authored Mar 1, 2024
1 parent d3bf111 commit 622200a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion internal/aws/proxy/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ func TestCanCreateTransport(t *testing.T) {

_, err := NewServer(cfg, logger)
assert.Error(t, err, "NewServer should fail")
assert.Contains(t, err.Error(), "failed to parse proxy URL")
assert.Contains(t, err.Error(), "invalid control character in URL")
}

func TestGetServiceEndpointInvalidAWSConfig(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion receiver/awsxrayreceiver/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestCreateTracesReceiver(t *testing.T) {
t.Skip()
}

t.Setenv(defaultRegionEnvName, mockRegion)
t.Setenv(regionEnvName, mockRegion)

factory := NewFactory()
_, err := factory.CreateTracesReceiver(
Expand Down
18 changes: 9 additions & 9 deletions receiver/awsxrayreceiver/receiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ import (
)

const (
segmentHeader = "{\"format\": \"json\", \"version\": 1}\n"
defaultRegionEnvName = "AWS_DEFAULT_REGION"
mockRegion = "us-west-2"
segmentHeader = "{\"format\": \"json\", \"version\": 1}\n"
regionEnvName = "AWS_REGION"
mockRegion = "us-west-2"
)

func TestConsumerCantBeNil(t *testing.T) {
Expand Down Expand Up @@ -114,7 +114,7 @@ func TestSegmentsPassedToConsumer(t *testing.T) {
assert.NoError(t, tt.Shutdown(context.Background()))
}()

t.Setenv(defaultRegionEnvName, mockRegion)
t.Setenv(regionEnvName, mockRegion)

addr, rcvr, _ := createAndOptionallyStartReceiver(t, nil, true, receiver.CreateSettings{ID: receiverID, TelemetrySettings: tt.TelemetrySettings, BuildInfo: component.NewDefaultBuildInfo()})
defer func() {
Expand Down Expand Up @@ -145,7 +145,7 @@ func TestTranslatorErrorsOut(t *testing.T) {
assert.NoError(t, tt.Shutdown(context.Background()))
}()

t.Setenv(defaultRegionEnvName, mockRegion)
t.Setenv(regionEnvName, mockRegion)

addr, rcvr, recordedLogs := createAndOptionallyStartReceiver(t, nil, true, receiver.CreateSettings{ID: receiverID, TelemetrySettings: tt.TelemetrySettings, BuildInfo: component.NewDefaultBuildInfo()})
defer func() {
Expand All @@ -172,7 +172,7 @@ func TestSegmentsConsumerErrorsOut(t *testing.T) {
assert.NoError(t, tt.Shutdown(context.Background()))
}()

t.Setenv(defaultRegionEnvName, mockRegion)
t.Setenv(regionEnvName, mockRegion)

addr, rcvr, recordedLogs := createAndOptionallyStartReceiver(t, consumertest.NewErr(errors.New("can't consume traces")), true, receiver.CreateSettings{ID: receiverID, TelemetrySettings: tt.TelemetrySettings, BuildInfo: component.NewDefaultBuildInfo()})
defer func() {
Expand Down Expand Up @@ -202,7 +202,7 @@ func TestPollerCloseError(t *testing.T) {
assert.NoError(t, tt.Shutdown(context.Background()))
}()

t.Setenv(defaultRegionEnvName, mockRegion)
t.Setenv(regionEnvName, mockRegion)

_, rcvr, _ := createAndOptionallyStartReceiver(t, nil, false, receiver.CreateSettings{ID: receiverID, TelemetrySettings: tt.TelemetrySettings, BuildInfo: component.NewDefaultBuildInfo()})
mPoller := &mockPoller{closeErr: errors.New("mockPollerCloseErr")}
Expand All @@ -220,7 +220,7 @@ func TestProxyCloseError(t *testing.T) {
assert.NoError(t, tt.Shutdown(context.Background()))
}()

t.Setenv(defaultRegionEnvName, mockRegion)
t.Setenv(regionEnvName, mockRegion)

_, rcvr, _ := createAndOptionallyStartReceiver(t, nil, false, receiver.CreateSettings{ID: receiverID, TelemetrySettings: tt.TelemetrySettings, BuildInfo: component.NewDefaultBuildInfo()})
mProxy := &mockProxy{closeErr: errors.New("mockProxyCloseErr")}
Expand All @@ -238,7 +238,7 @@ func TestBothPollerAndProxyCloseError(t *testing.T) {
assert.NoError(t, tt.Shutdown(context.Background()))
}()

t.Setenv(defaultRegionEnvName, mockRegion)
t.Setenv(regionEnvName, mockRegion)

_, rcvr, _ := createAndOptionallyStartReceiver(t, nil, false, receiver.CreateSettings{ID: receiverID, TelemetrySettings: tt.TelemetrySettings, BuildInfo: component.NewDefaultBuildInfo()})
mPoller := &mockPoller{closeErr: errors.New("mockPollerCloseErr")}
Expand Down

0 comments on commit 622200a

Please sign in to comment.