func TestCreateHelloWorldNewInstances(t *testing.T) {
	resHello1 := gocf.NewResourceByType(HelloWorld)
	customResource1 := resHello1.(*HelloWorldResource)

	resHello2 := gocf.NewResourceByType(HelloWorld)
	customResource2 := resHello2.(*HelloWorldResource)

	if &customResource1 == &customResource2 {
		t.Errorf("gocf.NewResourceByType failed to make new instances")
	}
}
Ejemplo n.º 2
0
func newCloudFormationResource(resourceType string, logger *logrus.Logger) (gocf.ResourceProperties, error) {
	resProps := gocf.NewResourceByType(resourceType)
	if nil == resProps {
		logger.WithFields(logrus.Fields{
			"Type": resourceType,
		}).Fatal("Failed to create CloudFormation CustomResource!")
		return nil, fmt.Errorf("Unsupported CustomResourceType: %s", resourceType)
	}
	return resProps, nil
}
func TestExecuteCreateHelloWorld(t *testing.T) {
	resHello1 := gocf.NewResourceByType(HelloWorld)
	customResource1 := resHello1.(*HelloWorldResource)
	customResource1.Message = "Create resource here"

	logger := logrus.New()
	awsSession := awsSession(logger)
	createOutputs, createError := customResource1.create(awsSession, logger)
	if nil != createError {
		t.Errorf("Failed to create HelloWorldResource: %s", createError)
	}
	t.Logf("HelloWorldResource outputs: %s", createOutputs)
}
func TestUnzip(t *testing.T) {
	resUnzip := gocf.NewResourceByType(ZipToS3Bucket)
	zipResource := resUnzip.(*ZipToS3BucketResource)
	zipResource.DestBucket = gocf.String(os.Getenv("TEST_DEST_S3_BUCKET"))
	zipResource.SrcBucket = gocf.String(os.Getenv("TEST_SRC_S3_BUCKET"))
	zipResource.SrcKeyName = gocf.String(os.Getenv("TEST_SRC_S3_KEY"))
	zipResource.Manifest = map[string]interface{}{
		"Some": "Data",
	}
	// Put it
	logger := logrus.New()
	awsSession := awsSession(logger)
	createOutputs, createError := zipResource.create(awsSession, logger)
	if nil != createError {
		t.Errorf("Failed to create Unzip resource: %s", createError)
	}
	t.Logf("TestUnzip outputs: %#v", createOutputs)

	deleteOutputs, deleteError := zipResource.delete(awsSession, logger)
	if nil != deleteError {
		t.Errorf("Failed to create Unzip resource: %s", createError)
	}
	t.Logf("TestUnzip outputs: %#v", deleteOutputs)
}
func TestCreateHelloWorld(t *testing.T) {
	resHello := gocf.NewResourceByType(HelloWorld)
	customResource := resHello.(*HelloWorldResource)
	customResource.Message = "Hello world"
}