Skip to content

Commit

Permalink
Test that we can successfully compare templates parsed by the parse p…
Browse files Browse the repository at this point in the history
…ackage
  • Loading branch information
stilvoid committed Jun 3, 2019
1 parent ceadd4e commit 949bf71
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions diff/template_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package diff

import (
"testing"

"github.com/aws-cloudformation/rain/parse"
)

const a = `Parameters:
BucketName:
Type: String
Resources:
Bucket:
Type: AWS::S3::Bucket
Properties:
BucketName: !Ref BucketName
Outputs:
BucketArn:
Value: !GetAtt Bucket.Arn
`

const b = `Parameters:
BucketName:
Type: String
Resources:
Bucket:
Type: AWS::S3::Bucket
Properties:
BucketName:
Ref: BucketName
Outputs:
BucketArn:
Value:
Fn::GetAtt:
- Bucket
- Arn
`

func TestCompareTemplateIntrinsics(t *testing.T) {
at, err := parse.ReadString(a)
if err != nil {
t.Error(err)
}

bt, err := parse.ReadString(b)
if err != nil {
t.Error(err)
}

actual := Compare(at, bt)

if actual != Unchanged {
t.Errorf("Templates are not equal! %s", Format(actual))
}
}

0 comments on commit 949bf71

Please sign in to comment.