File: main_test.go

package info (click to toggle)
golang-github-aws-aws-sdk-go 1.49.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 312,636 kB
  • sloc: makefile: 120
file content (49 lines) | stat: -rw-r--r-- 1,147 bytes parent folder | download | duplicates (2)
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
package endpoints

import (
	"fmt"
	"os"
	"path/filepath"
	"testing"
)

// Update all endpoints partition variables data to be the static testdata
// model instead of the dynamic live model. This ensures that endpoint tests
// are tested against static data, and will not break when the live
// endpoints.json model is updated.

func TestMain(m *testing.M) {
	testdataFilename := filepath.Join("testdata", "endpoints.json")

	testdataFile, err := os.Open(testdataFilename)
	if err != nil {
		panic(fmt.Sprintf("failed to open test endpoints model, %v", err))
	}

	resolver, err := DecodeModel(testdataFile)
	if err != nil {
		panic(fmt.Sprintf("failed to decode test endpoints model, %v", err))
	}

	partitions, ok := resolver.(partitions)
	if !ok {
		panic(fmt.Sprintf("expect %T resolver, got %T", partitions, resolver))
	}

	for _, p := range partitions {
		switch p.ID {
		case "aws":
			awsPartition = p
		case "aws-cn":
			awscnPartition = p
		case "aws-us-gov":
			awsusgovPartition = p
		case "aws-iso":
			awsisoPartition = p
		case "aws-iso-b":
			awsisobPartition = p
		default:
			panic("unknown endpoints partition " + p.ID)
		}
	}
}