Skip to content

Commit

Permalink
fix #510
Browse files Browse the repository at this point in the history
  • Loading branch information
shogo82148 committed Nov 21, 2023
1 parent 83d2712 commit 62ce2d9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
24 changes: 14 additions & 10 deletions xrayaws-v2/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/aws/aws-sdk-go-v2/aws"
awshttp "github.com/aws/aws-sdk-go-v2/aws/transport/http"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/credentials"
"github.com/aws/aws-sdk-go-v2/service/lambda"
"github.com/google/go-cmp/cmp"
"github.com/shogo82148/aws-xray-yasdk-go/xray"
Expand Down Expand Up @@ -100,7 +101,7 @@ func TestClient(t *testing.T) {
WithXRay()(&opt)
cfg := aws.Config{
Region: "fake-moon-1",
EndpointResolver: aws.EndpointResolverFunc(func(service, region string) (aws.Endpoint, error) {
EndpointResolverWithOptions: aws.EndpointResolverWithOptionsFunc(func(service, region string, options ...interface{}) (aws.Endpoint, error) {
return aws.Endpoint{
URL: ts.URL,
SigningName: "lambda",
Expand All @@ -109,7 +110,8 @@ func TestClient(t *testing.T) {
Retryer: func() aws.Retryer {
return aws.NopRetryer{}
},
APIOptions: opt.APIOptions,
APIOptions: opt.APIOptions,
Credentials: credentials.NewStaticCredentialsProvider("AKIAIOSFODNN7EXAMPLE", "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", ""),
}

// start testing
Expand All @@ -134,7 +136,7 @@ func TestClient(t *testing.T) {
EndTime: timeFilled,
Subsegments: []*schema.Segment{
{
Name: "lambda",
Name: "none",
ID: "xxxxxxxxxxxxxxxx",
Namespace: "aws",
StartTime: timeFilled,
Expand Down Expand Up @@ -219,7 +221,7 @@ func TestClient_FailDial(t *testing.T) {
WithXRay()(&opt)
cfg := aws.Config{
Region: "fake-moon-1",
EndpointResolver: aws.EndpointResolverFunc(func(service, region string) (aws.Endpoint, error) {
EndpointResolverWithOptions: aws.EndpointResolverWithOptionsFunc(func(service, region string, options ...interface{}) (aws.Endpoint, error) {
return aws.Endpoint{
// we expected no Gopher daemon on this computer ʕ◔ϖ◔ʔ
URL: "http://127.0.0.1:70",
Expand All @@ -229,7 +231,8 @@ func TestClient_FailDial(t *testing.T) {
Retryer: func() aws.Retryer {
return aws.NopRetryer{}
},
APIOptions: opt.APIOptions,
APIOptions: opt.APIOptions,
Credentials: credentials.NewStaticCredentialsProvider("AKIAIOSFODNN7EXAMPLE", "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", ""),
}

// start testing
Expand Down Expand Up @@ -263,7 +266,7 @@ func TestClient_FailDial(t *testing.T) {
EndTime: timeFilled,
Subsegments: []*schema.Segment{
{
Name: "lambda",
Name: "none",
ID: "xxxxxxxxxxxxxxxx",
Namespace: "aws",
StartTime: timeFilled,
Expand Down Expand Up @@ -371,7 +374,7 @@ func TestClient_BadRequest(t *testing.T) {
WithXRay()(&opt)
cfg := aws.Config{
Region: "fake-moon-1",
EndpointResolver: aws.EndpointResolverFunc(func(service, region string) (aws.Endpoint, error) {
EndpointResolverWithOptions: aws.EndpointResolverWithOptionsFunc(func(service, region string, options ...interface{}) (aws.Endpoint, error) {
return aws.Endpoint{
URL: ts.URL,
SigningName: "lambda",
Expand All @@ -380,7 +383,8 @@ func TestClient_BadRequest(t *testing.T) {
Retryer: func() aws.Retryer {
return aws.NopRetryer{}
},
APIOptions: opt.APIOptions,
APIOptions: opt.APIOptions,
Credentials: credentials.NewStaticCredentialsProvider("AKIAIOSFODNN7EXAMPLE", "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", ""),
}

// start testing
Expand All @@ -394,7 +398,7 @@ func TestClient_BadRequest(t *testing.T) {
awsErr := err
var httpErr *awshttp.ResponseError
if !errors.As(err, &httpErr) {
t.Error("expected *smithyhttp.ResponseError, but not")
t.Fatalf("expected *smithyhttp.ResponseError, but got %T", err)
}

// check the segment
Expand All @@ -414,7 +418,7 @@ func TestClient_BadRequest(t *testing.T) {
EndTime: timeFilled,
Subsegments: []*schema.Segment{
{
Name: "lambda",
Name: "none",
ID: "xxxxxxxxxxxxxxxx",
Namespace: "aws",
StartTime: timeFilled,
Expand Down
2 changes: 1 addition & 1 deletion xrayaws-v2/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.18
require (
github.com/aws/aws-sdk-go-v2 v1.23.1
github.com/aws/aws-sdk-go-v2/config v1.25.4
github.com/aws/aws-sdk-go-v2/credentials v1.16.3
github.com/aws/aws-sdk-go-v2/service/lambda v1.48.1
github.com/aws/smithy-go v1.17.0
github.com/davecgh/go-spew v1.1.1 // indirect
Expand All @@ -15,7 +16,6 @@ require (

require (
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.5.1 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.16.3 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.14.5 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.2.4 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.5.4 // indirect
Expand Down

0 comments on commit 62ce2d9

Please sign in to comment.