File: platform_handlers_go1.6_test.go

package info (click to toggle)
golang-github-aws-aws-sdk-go 1.44.133-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bookworm-proposed-updates
  • size: 245,296 kB
  • sloc: makefile: 120
file content (84 lines) | stat: -rw-r--r-- 2,117 bytes parent folder | download
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//go:build go1.6
// +build go1.6

package s3_test

import (
	"bytes"
	"testing"

	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/awstesting/unit"
	"github.com/aws/aws-sdk-go/service/s3"
)

func TestAdd100Continue_Added(t *testing.T) {
	svc := s3.New(unit.Session)
	r, _ := svc.PutObjectRequest(&s3.PutObjectInput{
		Bucket: aws.String("bucket"),
		Key:    aws.String("dest"),
		Body:   bytes.NewReader(make([]byte, 1024*1024*5)),
	})

	err := r.Sign()

	if err != nil {
		t.Errorf("expected no error, but received %v", err)
	}
	if e, a := "100-Continue", r.HTTPRequest.Header.Get("Expect"); e != a {
		t.Errorf("expected %s, but received %s", e, a)
	}
}

func TestAdd100Continue_SkipDisabled(t *testing.T) {
	svc := s3.New(unit.Session, aws.NewConfig().WithS3Disable100Continue(true))
	r, _ := svc.PutObjectRequest(&s3.PutObjectInput{
		Bucket: aws.String("bucket"),
		Key:    aws.String("dest"),
		Body:   bytes.NewReader(make([]byte, 1024*1024*5)),
	})

	err := r.Sign()

	if err != nil {
		t.Errorf("expected no error, but received %v", err)
	}
	if r.HTTPRequest.Header.Get("Expect") != "" {
		t.Errorf("expected empty value, but received %s", r.HTTPRequest.Header.Get("Expect"))
	}
}

func TestAdd100Continue_SkipNonPUT(t *testing.T) {
	svc := s3.New(unit.Session)
	r, _ := svc.GetObjectRequest(&s3.GetObjectInput{
		Bucket: aws.String("bucket"),
		Key:    aws.String("dest"),
	})

	err := r.Sign()

	if err != nil {
		t.Errorf("expected no error, but received %v", err)
	}
	if r.HTTPRequest.Header.Get("Expect") != "" {
		t.Errorf("expected empty value, but received %s", r.HTTPRequest.Header.Get("Expect"))
	}
}

func TestAdd100Continue_SkipTooSmall(t *testing.T) {
	svc := s3.New(unit.Session)
	r, _ := svc.PutObjectRequest(&s3.PutObjectInput{
		Bucket: aws.String("bucket"),
		Key:    aws.String("dest"),
		Body:   bytes.NewReader(make([]byte, 1024*1024*1)),
	})

	err := r.Sign()

	if err != nil {
		t.Errorf("expected no error, but received %v", err)
	}
	if r.HTTPRequest.Header.Get("Expect") != "" {
		t.Errorf("expected empty value, but received %s", r.HTTPRequest.Header.Get("Expect"))
	}
}