Skip to content

Commit c9021fc

Browse files
committed
Basic usage test
1 parent 8ac3406 commit c9021fc

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

tests/Unit/BasicUsageTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
<?php
22

33
use PHPUnit\Framework\TestCase;
4+
use DivineOmega\HCLParser\HCLParser;
45

56
class BasicUsageTest extends TestCase
67
{
78
public function testBasicParsing()
89
{
9-
10+
$hcl = file_get_contents(__DIR__.'/data/example.tf');
11+
$configObject = (new HCLParser($hcl))->parse();
12+
13+
$expected = unserialize(file_get_contents(__DIR__.'/data/example.tf.expected'));
14+
15+
$this->assertEquals($expected, $configObject);
1016
}
1117

1218
}

tests/Unit/data/example.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
# Specify the provider and access details
3+
provider "aws" {
4+
access_key = "${var.access_key}"
5+
secret_key = "${var.secret_key}"
6+
region = "${var.region}"
7+
}
8+
9+
# Create an instance
10+
resource "aws_instance" "example" {
11+
ami = "ami-2757f631"
12+
instance_type = "t2.micro"
13+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
O:8:"stdClass":2:{s:8:"provider";a:1:{i:0;O:8:"stdClass":1:{s:3:"aws";a:1:{i:0;O:8:"stdClass":3:{s:10:"access_key";s:17:"${var.access_key}";s:6:"region";s:13:"${var.region}";s:10:"secret_key";s:17:"${var.secret_key}";}}}}s:8:"resource";a:1:{i:0;O:8:"stdClass":1:{s:12:"aws_instance";a:1:{i:0;O:8:"stdClass":1:{s:7:"example";a:1:{i:0;O:8:"stdClass":2:{s:3:"ami";s:12:"ami-2757f631";s:13:"instance_type";s:8:"t2.micro";}}}}}}}

0 commit comments

Comments
 (0)