mirror of
https://github.com/opentffoundation/opentf.git
synced 2025-12-19 09:48:32 -05:00
fix: internal/getprovider tests on Windows (#3275)
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
This commit is contained in:
committed by
GitHub
parent
f5ef40c37c
commit
9b14212207
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -2,4 +2,3 @@ internal/**/*.tf text eol=lf
|
|||||||
internal/**/*.tofu text eol=lf
|
internal/**/*.tofu text eol=lf
|
||||||
internal/**/*.json text eol=lf
|
internal/**/*.json text eol=lf
|
||||||
internal/**/*.tmpl text eol=lf
|
internal/**/*.tmpl text eol=lf
|
||||||
internal/providercache/testdata/**/* text eol=lf
|
|
||||||
@@ -11,6 +11,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
"slices"
|
"slices"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -240,7 +241,7 @@ func TestPackageHashAuthentication_failure(t *testing.T) {
|
|||||||
}{
|
}{
|
||||||
"missing file": {
|
"missing file": {
|
||||||
PackageLocalArchive("testdata/no-package-here.zip"),
|
PackageLocalArchive("testdata/no-package-here.zip"),
|
||||||
"failed to verify provider package checksums: lstat testdata/no-package-here.zip: " + syscall.ENOENT.Error(),
|
"failed to verify provider package checksums: " + statNotFoundErrorMsg("testdata/no-package-here.zip"),
|
||||||
},
|
},
|
||||||
"checksum mismatch": {
|
"checksum mismatch": {
|
||||||
PackageLocalDir("testdata/filesystem-mirror/registry.opentofu.org/hashicorp/null/2.0.0/linux_amd64"),
|
PackageLocalDir("testdata/filesystem-mirror/registry.opentofu.org/hashicorp/null/2.0.0/linux_amd64"),
|
||||||
@@ -304,7 +305,7 @@ func TestArchiveChecksumAuthentication_failure(t *testing.T) {
|
|||||||
}{
|
}{
|
||||||
"missing file": {
|
"missing file": {
|
||||||
PackageLocalArchive("testdata/no-package-here.zip"),
|
PackageLocalArchive("testdata/no-package-here.zip"),
|
||||||
"failed to compute checksum for testdata/no-package-here.zip: lstat testdata/no-package-here.zip: " + syscall.ENOENT.Error(),
|
"failed to compute checksum for testdata/no-package-here.zip: " + statNotFoundErrorMsg("testdata/no-package-here.zip"),
|
||||||
},
|
},
|
||||||
"checksum mismatch": {
|
"checksum mismatch": {
|
||||||
PackageLocalArchive("testdata/filesystem-mirror/registry.opentofu.org/hashicorp/null/terraform-provider-null_2.1.0_linux_amd64.zip"),
|
PackageLocalArchive("testdata/filesystem-mirror/registry.opentofu.org/hashicorp/null/terraform-provider-null_2.1.0_linux_amd64.zip"),
|
||||||
@@ -333,6 +334,16 @@ func TestArchiveChecksumAuthentication_failure(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// statNotFoundErrorMsg is used to return a string containing: the specific name of the syscall used by
|
||||||
|
// the operating system to check the existence of a file, the filename, and the error message.
|
||||||
|
func statNotFoundErrorMsg(filename string) string {
|
||||||
|
prefix := "lstat"
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
prefix = "GetFileAttributesEx"
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("%s %s: %s", prefix, filepath.FromSlash(filename), syscall.ENOENT.Error())
|
||||||
|
}
|
||||||
|
|
||||||
// Matching checksum authentication takes a SHA256SUMS document, an archive
|
// Matching checksum authentication takes a SHA256SUMS document, an archive
|
||||||
// filename, and an expected SHA256 hash. On success both return values should
|
// filename, and an expected SHA256 hash. On success both return values should
|
||||||
// be nil.
|
// be nil.
|
||||||
|
|||||||
1
internal/getproviders/testdata/.gitattributes
vendored
Normal file
1
internal/getproviders/testdata/.gitattributes
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
**/* text eol=lf
|
||||||
Reference in New Issue
Block a user