Example #1
0
func init() {
	var err error

	switch os.Getenv("PROVIDER") {
	case "aws":
		CurrentProvider, err = aws.NewProvider(os.Getenv("AWS_REGION"), os.Getenv("AWS_ACCESS"), os.Getenv("AWS_SECRET"), os.Getenv("AWS_ENDPOINT"))
	case "test":
		CurrentProvider = TestProvider
	default:
		die(fmt.Errorf("PROVIDER must be one of (aws)"))
	}

	if err != nil {
		die(err)
	}
}
Example #2
0
// StubAwsProvider creates an httptest server with canned Request / Response
// cycles, and sets CurrentProvider to a new AWS provider that uses
// the test server as the endpoint
func StubAwsProvider(cycles ...awsutil.Cycle) (s *httptest.Server) {
	handler := awsutil.NewHandler(cycles)
	s = httptest.NewServer(handler)

	os.Setenv("AWS_ACCESS", "test")
	os.Setenv("AWS_SECRET", "test")
	os.Setenv("AWS_ENDPOINT", s.URL)
	os.Setenv("AWS_REGION", "test")

	p, err := aws.NewProvider("test", "test", "test", s.URL)

	if err != nil {
		panic(err)
	}

	provider.CurrentProvider = p

	return s
}