Skip to content

Commit 1530938

Browse files
committed
chore(data_source_github_release_asset): improve acc test
This improves the `data_source_github_release_asset` acceptance tests to be more TF-focused via use of the `base64decode` function, per code review request of @stevehipwell: #2514 (comment) Signed-off-by: Mike Ball <[email protected]>
1 parent a48d02b commit 1530938

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

github/data_source_github_release_asset_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package github
22

33
import (
4-
"encoding/base64"
54
"fmt"
65
"testing"
76

@@ -15,7 +14,6 @@ func TestAccGithubReleaseAssetDataSource(t *testing.T) {
1514
testReleaseAssetID := testAccConf.testPublicRelaseAssetId
1615
testReleaseAssetName := testAccConf.testPublicRelaseAssetName
1716
testReleaseAssetContent := testAccConf.testPublicReleaseAssetContent
18-
base64EncodedAssetContent := base64.StdEncoding.EncodeToString([]byte(testReleaseAssetContent))
1917

2018
t.Run("queries and downloads specified asset ID", func(t *testing.T) {
2119
config := fmt.Sprintf(`
@@ -25,6 +23,10 @@ func TestAccGithubReleaseAssetDataSource(t *testing.T) {
2523
asset_id = "%s"
2624
download_file_contents = true
2725
}
26+
27+
output "github_release_asset_contents" {
28+
value = base64decode(data.github_release_asset.test.file_contents)
29+
}
2830
`, testReleaseRepository, testRepositoryOwner, testReleaseAssetID)
2931

3032
resource.Test(t, resource.TestCase{
@@ -39,9 +41,7 @@ func TestAccGithubReleaseAssetDataSource(t *testing.T) {
3941
resource.TestCheckResourceAttr(
4042
"data.github_release_asset.test", "name", testReleaseAssetName,
4143
),
42-
resource.TestCheckResourceAttr(
43-
"data.github_release_asset.test", "file_contents", base64EncodedAssetContent,
44-
),
44+
resource.TestCheckOutput("github_release_asset_contents", testReleaseAssetContent),
4545
),
4646
},
4747
},

0 commit comments

Comments
 (0)