@@ -3,6 +3,7 @@ package xterrafile
33import (
44 "testing"
55
6+ "github.com/hashicorp/terraform/registry"
67 "github.com/hashicorp/terraform/registry/test"
78 "github.com/stretchr/testify/assert"
89)
@@ -22,16 +23,7 @@ func TestIsRegistrySourceAddr(t *testing.T) {
2223}
2324
2425func TestGetRegistrySource (t * testing.T ) {
25- assert .True (t , GetRegistrySource (
26- "droplet" ,
27- "terraform-digitalocean-modules/droplet/digitalocean" ,
28- ">=0.1.2" ),
29- "private registry path with sub-path should be true" )
30- // assert.True(t, GetRegistrySource(
31- // "droplet2",
32- // "app.terraform.io/terraform-digitalocean-modules/droplet/digitalocean",
33- // ">= 1.0.0"),
34- // "private registry path with sub-path should be true")
26+
3527}
3628
3729func TestGetModSrc (t * testing.T ) {
@@ -55,17 +47,19 @@ func TestGetRegistryVersion(t *testing.T) {
5547 server := test .Registry ()
5648 defer server .Close ()
5749
50+ testClient := registry .NewClient (test .Disco (server ), nil )
51+
5852 modSrc , _ := getModSrc ("example.com/test-versions/name/provider" )
59- version , _ := getRegistryVersion (modSrc , ">= 2.0.0 < 2.2.0" , test . Disco ( server ) )
53+ version , _ := getRegistryVersion (testClient , modSrc , ">= 2.0.0 < 2.2.0" )
6054 assert .Equal (t , "2.1.1" , version , "version should be >= 2.0.0 < 2.2.0" )
6155
62- _ , err := getRegistryVersion (modSrc , ">= 3.0.0" , test . Disco ( server ) )
56+ _ , err := getRegistryVersion (testClient , modSrc , ">= 3.0.0" )
6357 assert .Error (t , err , "should have returned an error" )
6458
65- _ , err = getRegistryVersion (modSrc , "not.a.version" , test . Disco ( server ) )
59+ _ , err = getRegistryVersion (testClient , modSrc , "not.a.version" )
6660 assert .Error (t , err , "should return an error" )
6761
6862 modSrc , _ = getModSrc ("invalid.com/test-versions/name/provider" )
69- _ , err = getRegistryVersion (modSrc , ">= 3.0.0" , test . Disco ( server ) )
63+ _ , err = getRegistryVersion (testClient , modSrc , ">= 3.0.0" )
7064 assert .Error (t , err , "should return an error" )
7165}
0 commit comments