provider/archive: Test that archive_file hashes seem plausible
We just check these for syntax rather than exact value because the underlying archive library is free to evolve its exact encoding over time as long as the result is semantically equivalent, and we don't want these tests to break when we build on different versions of Go.
This commit is contained in:
parent
ea93b91a80
commit
6ad1e596dd
|
@ -3,6 +3,7 @@ package archive
|
|||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"regexp"
|
||||
"testing"
|
||||
|
||||
r "github.com/hashicorp/terraform/helper/resource"
|
||||
|
@ -19,6 +20,21 @@ func TestAccArchiveFile_Basic(t *testing.T) {
|
|||
Check: r.ComposeTestCheckFunc(
|
||||
testAccArchiveFileExists("zip_file_acc_test.zip", &fileSize),
|
||||
r.TestCheckResourceAttrPtr("data.archive_file.foo", "output_size", &fileSize),
|
||||
|
||||
// We just check the hashes for syntax rather than exact
|
||||
// content since we don't want to break if the archive
|
||||
// library starts generating different bytes that are
|
||||
// functionally equivalent.
|
||||
r.TestMatchResourceAttr(
|
||||
"data.archive_file.foo", "output_base64sha256",
|
||||
regexp.MustCompile(`^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$`),
|
||||
),
|
||||
r.TestMatchResourceAttr(
|
||||
"data.archive_file.foo", "output_md5", regexp.MustCompile(`^[0-9a-f]{32}$`),
|
||||
),
|
||||
r.TestMatchResourceAttr(
|
||||
"data.archive_file.foo", "output_sha", regexp.MustCompile(`^[0-9a-f]{40}$`),
|
||||
),
|
||||
),
|
||||
},
|
||||
r.TestStep{
|
||||
|
|
Loading…
Reference in New Issue