<commit_before>package aws

import (
	"fmt"
	"log"
	"os"
	"testing"
	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/aws/session"
	cf "github.com/aws/aws-sdk-go/service/cloudformation"
	"github.com/satori/go.uuid"
)

var (
	keyPair string
	region string

	sess *session.Session
	svc *cf.CloudFormation
)

// REQUIREMENTS:
// AWS credentials in path
// Environment variables set for the following:
//   KEYPAIR=<your-aws-key-pair>
//   REGION=<aws-region>
func init() {
	keyPair = os.Getenv("KEYPAIR")
	if keyPair == "" {
		log.Fatal("KEYPAIR environment variable not set")
	}
	region = os.Getenv("REGION")
	if region == "" {
		log.Fatal("REGION environment variable not set")
	}
}

func TestMain(m *testing.M) {
	setup()
	code := m.Run()
	teardown()
	os.Exit(code)
}

func setup() {
	sess = session.Must(session.NewSession())

	// Create the service's client with the session.
	svc = cf.New(sess,
		aws.NewConfig().WithRegion(region).WithLogLevel(aws.LogOff))
}

func teardown() {
	// TODO destroy test stacks
}

func TestCreate(t *testing.T) {
	stackName := fmt.Sprintf("amp-aws-plugin-test-%s", uuid.NewV4())

	stackSpec := &StackSpec{
		KeyPair: keyPair,
		Region: region,
		StackName: stackName,
		OnFailure: "DELETE",
	}

	stackSpec.Params = []*cf.Parameter{
		{ParameterKey: aws.String("KeyName"), ParameterValue: aws.String(keyPair)},
	}

	_, err := CreateStack(svc, stackSpec, 20)
	if err != nil {
		t.Fatal(err)
	}
}<commit_msg>add keypair to personally identify test stack names<commit_after>package aws

import (
	"fmt"
	"log"
	"os"
	"testing"
	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/aws/session"
	cf "github.com/aws/aws-sdk-go/service/cloudformation"
	"github.com/satori/go.uuid"
)

var (
	keyPair string
	region string

	sess *session.Session
	svc *cf.CloudFormation
)

// REQUIREMENTS:
// AWS credentials in path
// Environment variables set for the following:
//   KEYPAIR=<your-aws-key-pair>
//   REGION=<aws-region>
func init() {
	keyPair = os.Getenv("KEYPAIR")
	if keyPair == "" {
		log.Fatal("KEYPAIR environment variable not set")
	}
	region = os.Getenv("REGION")
	if region == "" {
		log.Fatal("REGION environment variable not set")
	}
}

func TestMain(m *testing.M) {
	setup()
	code := m.Run()
	teardown()
	os.Exit(code)
}

func setup() {
	sess = session.Must(session.NewSession())

	// Create the service's client with the session.
	svc = cf.New(sess,
		aws.NewConfig().WithRegion(region).WithLogLevel(aws.LogOff))
}

func teardown() {
	// TODO destroy test stacks
}

func TestCreate(t *testing.T) {
	stackName := fmt.Sprintf("%s-plugin-test-%s", keyPair, uuid.NewV4())

	stackSpec := &StackSpec{
		KeyPair: keyPair,
		Region: region,
		StackName: stackName,
		OnFailure: "DELETE",
	}

	stackSpec.Params = []*cf.Parameter{
		{ParameterKey: aws.String("KeyName"), ParameterValue: aws.String(keyPair)},
	}

	_, err := CreateStack(svc, stackSpec, 20)
	if err != nil {
		t.Fatal(err)
	}
}
{'fraction_non_alphanumeric': 0.16224489795918368, 'fraction_numerical': 0.0020408163265306124, 'mean_word_length': 3.934563758389262, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1665360', 'n_tokens_mistral': 1155, 'n_tokens_neox': 1120, 'n_words': 232}