Skip to content

Commit

Permalink
fixup! feat: Add vcsBaseCommitSha to estimate metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
vdmgolub committed May 5, 2024
1 parent a7b72c4 commit f5be293
Show file tree
Hide file tree
Showing 11 changed files with 2,191 additions and 0 deletions.
20 changes: 20 additions & 0 deletions cmd/infracost/diff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,26 @@ func TestDiffWithCompareToFormatJSON(t *testing.T) {
)
}

func TestDiffWithCompareToNoMetadataFormatJSON(t *testing.T) {
dir := path.Join("./testdata", testutil.CalcGoldenFileTestdataDirName())
GoldenFileCommandTest(
t,
testutil.CalcGoldenFileTestdataDirName(),
[]string{
"diff",
"--path",
dir,
"--compare-to",
path.Join(dir, "prior.json"),
"--format",
"json",
}, &GoldenFileOptions{
RunTerraformCLI: true,
IsJSON: true,
},
)
}

func TestDiffWithCompareToPreserveSummary(t *testing.T) {
dir := path.Join("./testdata", testutil.CalcGoldenFileTestdataDirName())
GoldenFileCommandTest(
Expand Down
6 changes: 6 additions & 0 deletions cmd/infracost/output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ func TestOutputFormatJSON(t *testing.T) {
GoldenFileCommandTest(t, testutil.CalcGoldenFileTestdataDirName(), []string{"output", "--format", "json", "--path", "./testdata/example_out.json", "--path", "./testdata/azure_firewall_out.json"}, opts)
}

func TestOutputDiffFormatJSON(t *testing.T) {
opts := DefaultOptions()
opts.IsJSON = true
GoldenFileCommandTest(t, testutil.CalcGoldenFileTestdataDirName(), []string{"output", "--format", "json", "--path", "./testdata/example_diff_out.json"}, opts)
}

func TestOutputFormatBitbucketCommentWithProjectNames(t *testing.T) {
testName := testutil.CalcGoldenFileTestdataDirName()
GoldenFileCommandTest(t, testName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"metadata": {
"infracostCommand": "diff",
"vcsBranch": "stub-branch",
"vcsBaseCommitSha": "71785af96bce822bd54f359d0883cfa4ca805432",
"vcsCommitSha": "stub-sha",
"vcsCommitAuthorName": "stub-author",
"vcsCommitAuthorEmail": "[email protected]",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"metadata": {
"infracostCommand": "diff",
"vcsBranch": "stub-branch",
"vcsBaseCommitSha": "71785af96bce822bd54f359d0883cfa4ca805432",
"vcsCommitSha": "stub-sha",
"vcsCommitAuthorName": "stub-author",
"vcsCommitAuthorEmail": "[email protected]",
Expand Down
10 changes: 10 additions & 0 deletions cmd/infracost/testdata/diff_with_compare_to_format_json/prior.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{
"version": "0.2",
"metadata": {
"infracostCommand": "breakdown",
"vcsBranch": "master",
"vcsCommitSha": "71785af96bce822bd54f359d0883cfa4ca805432",
"vcsCommitAuthorName": "Hugo",
"vcsCommitAuthorEmail": "",
"vcsCommitTimestamp": "2024-02-23T11:04:26Z",
"vcsCommitMessage": "wip",
"vcsRepositoryUrl": "https://github.com/infracost/infracost.git"
},
"currency": "USD",
"projects": [
{
Expand Down

0 comments on commit f5be293

Please sign in to comment.