File: apiversion_test.go

package info (click to toggle)
golang-github-aws-aws-sdk-go-v2 1.30.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 662,428 kB
  • sloc: java: 16,875; makefile: 432; sh: 175
file content (37 lines) | stat: -rw-r--r-- 1,017 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package customizations

import (
	"context"
	"github.com/aws/smithy-go/middleware"
	smithyhttp "github.com/aws/smithy-go/transport/http"
	"testing"
)

func TestGlacierAPIVersionMiddleware(t *testing.T) {
	apiVersion := "2012-06-01"
	m := &GlacierAPIVersion{apiVersion: apiVersion}

	_, _, err := m.HandleSerialize(context.Background(),
		middleware.SerializeInput{
			Request: smithyhttp.NewStackRequest(),
		},
		middleware.SerializeHandlerFunc(
			func(ctx context.Context, input middleware.SerializeInput) (
				output middleware.SerializeOutput, metadata middleware.Metadata, err error,
			) {
				req, ok := input.Request.(*smithyhttp.Request)
				if !ok || req == nil {
					t.Fatalf("expect smithy request, got %T", input.Request)
				}

				actual := req.Header.Get(glacierAPIVersionHeaderKey)
				if actual != apiVersion {
					t.Errorf("expect %s glacier version, got %s", apiVersion, actual)
				}
				return output, metadata, err
			}),
	)
	if err != nil {
		t.Fatalf("expect no error, got %v", err)
	}
}