github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/provider/equinix/testing_test.go (about) 1 // Copyright 2021 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package equinix_test 5 6 import ( 7 jc "github.com/juju/testing/checkers" 8 gc "gopkg.in/check.v1" 9 10 "github.com/juju/juju/cloud" 11 environscloudspec "github.com/juju/juju/environs/cloudspec" 12 "github.com/juju/juju/environs/config" 13 "github.com/juju/juju/testing" 14 ) 15 16 func fakeConfig(c *gc.C, attrs ...testing.Attrs) *config.Config { 17 cfg, err := testing.ModelConfig(c).Apply(fakeConfigAttrs(attrs...)) 18 c.Assert(err, jc.ErrorIsNil) 19 return cfg 20 } 21 22 func fakeConfigAttrs(attrs ...testing.Attrs) testing.Attrs { 23 merged := testing.FakeConfig().Merge(testing.Attrs{ 24 "type": "equinix", 25 "uuid": "ba532cc4-bc84-11eb-8529-0242ac130003", 26 }) 27 for _, attrs := range attrs { 28 merged = merged.Merge(attrs) 29 } 30 return merged 31 } 32 33 func fakeCloudSpec() environscloudspec.CloudSpec { 34 cred := fakeCredential() 35 return environscloudspec.CloudSpec{ 36 Type: "equinix", 37 Name: "equinix", 38 Region: "am", 39 Endpoint: "juju", 40 Credential: &cred, 41 } 42 } 43 44 func fakeCredential() cloud.Credential { 45 return cloud.NewCredential(cloud.UserPassAuthType, map[string]string{ 46 "project-id": "proj-juju-test", 47 "api-token": "password1", 48 }) 49 }