From 949bf711ffe7e1a0ac2337a1015272ea28db8cfa Mon Sep 17 00:00:00 2001 From: Steve Engledow Date: Mon, 3 Jun 2019 17:59:52 +0100 Subject: [PATCH] Test that we can successfully compare templates parsed by the parse package --- diff/template_test.go | 55 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 diff/template_test.go diff --git a/diff/template_test.go b/diff/template_test.go new file mode 100644 index 00000000..f8a7e6cb --- /dev/null +++ b/diff/template_test.go @@ -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)) + } +}