File: smoke_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 (59 lines) | stat: -rw-r--r-- 1,452 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//go:build integration
// +build integration

package workspaces

import (
	"context"
	"errors"
	"testing"
	"time"

	"github.com/aws/aws-sdk-go-v2/aws"
	"github.com/aws/aws-sdk-go-v2/service/internal/integrationtest"
	"github.com/aws/aws-sdk-go-v2/service/workspaces"
	"github.com/aws/smithy-go"
)

func TestInteg_00_DescribeWorkspaces(t *testing.T) {
	ctx, cancelFn := context.WithTimeout(context.Background(), 5*time.Second)
	defer cancelFn()

	cfg, _ := integrationtest.LoadConfigWithDefaultRegion("us-west-2")
	svc := workspaces.NewFromConfig(cfg)

	input := &workspaces.DescribeWorkspacesInput{}
	_, err := svc.DescribeWorkspaces(ctx, input)

	if err != nil {
		t.Errorf("expect no error, got %v", err)
	}
}

func TestInteg_01_DescribeWorkspaces(t *testing.T) {
	ctx, cancelFn := context.WithTimeout(context.Background(), 5*time.Second)
	defer cancelFn()

	cfg, _ := integrationtest.LoadConfigWithDefaultRegion("us-west-2")
	svc := workspaces.NewFromConfig(cfg)

	input := &workspaces.DescribeWorkspacesInput{
		DirectoryId: aws.String("fake-id"),
	}
	_, err := svc.DescribeWorkspaces(ctx, input)

	if err == nil {
		t.Errorf("expect request to fail")
	}

	var apiErr smithy.APIError
	if !errors.As(err, &apiErr) {
		t.Fatalf("expect error to be API error, was not, %v", err)
	}
	if len(apiErr.ErrorCode()) == 0 {
		t.Errorf("expect non-empty error code")
	}
	if len(apiErr.ErrorMessage()) == 0 {
		t.Errorf("expect non-empty error message")
	}
}