remove extra slash from registry urls
A refactor introduced an extra `/` in the download url, which causes an extra redirect during discovery. Improve a registry test to verify that detection doesn't require the registry after the modules have been fetched.
This commit is contained in:
parent
7a2af23d25
commit
1fbb2d611a
|
@ -79,7 +79,7 @@ func getStorage(s getter.Storage, key string, src string, mode GetMode) (string,
|
|||
}
|
||||
|
||||
const (
|
||||
registryAPI = "https://registry.terraform.io/v1/modules/"
|
||||
registryAPI = "https://registry.terraform.io/v1/modules"
|
||||
xTerraformGet = "X-Terraform-Get"
|
||||
)
|
||||
|
||||
|
|
|
@ -102,7 +102,7 @@ func TestDetectRegistry(t *testing.T) {
|
|||
defer server.Close()
|
||||
|
||||
detector := registryDetector{
|
||||
api: server.URL + "/v1/modules/",
|
||||
api: server.URL + "/v1/modules",
|
||||
client: server.Client(),
|
||||
}
|
||||
|
||||
|
@ -181,7 +181,7 @@ func TestDetectors(t *testing.T) {
|
|||
}
|
||||
|
||||
regDetector := ®istryDetector{
|
||||
api: server.URL + "/v1/modules/",
|
||||
api: server.URL + "/v1/modules",
|
||||
client: server.Client(),
|
||||
}
|
||||
|
||||
|
@ -280,7 +280,7 @@ func TestRegistryGitHubArchive(t *testing.T) {
|
|||
defer server.Close()
|
||||
|
||||
regDetector := ®istryDetector{
|
||||
api: server.URL + "/v1/modules/",
|
||||
api: server.URL + "/v1/modules",
|
||||
client: server.Client(),
|
||||
}
|
||||
|
||||
|
@ -312,6 +312,18 @@ func TestRegistryGitHubArchive(t *testing.T) {
|
|||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
// stop the registry server, and make sure that we don't need to call out again
|
||||
server.Close()
|
||||
tree = NewTree("", testConfig(t, "registry-tar-subdir"))
|
||||
|
||||
if err := tree.Load(storage, GetModeGet); err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
if !tree.Loaded() {
|
||||
t.Fatal("should be loaded")
|
||||
}
|
||||
|
||||
actual := strings.TrimSpace(tree.String())
|
||||
expected := strings.TrimSpace(treeLoadSubdirStr)
|
||||
if actual != expected {
|
||||
|
|
Loading…
Reference in New Issue