github.com/ctrox/terraform@v0.11.12-beta1/state/remote/artifactory_test.go (about) 1 package remote 2 3 import ( 4 "testing" 5 ) 6 7 func TestArtifactoryClient_impl(t *testing.T) { 8 var _ Client = new(ArtifactoryClient) 9 } 10 11 func TestArtifactoryFactory(t *testing.T) { 12 // This test just instantiates the client. Shouldn't make any actual 13 // requests nor incur any costs. 14 15 config := make(map[string]string) 16 17 // Empty config is an error 18 _, err := artifactoryFactory(config) 19 if err == nil { 20 t.Fatalf("Empty config should be error") 21 } 22 23 config["url"] = "http://artifactory.local:8081/artifactory" 24 config["repo"] = "terraform-repo" 25 config["subpath"] = "myproject" 26 27 // For this test we'll provide the credentials as config. The 28 // acceptance tests implicitly test passing credentials as 29 // environment variables. 30 config["username"] = "test" 31 config["password"] = "testpass" 32 33 client, err := artifactoryFactory(config) 34 if err != nil { 35 t.Fatalf("Error for valid config") 36 } 37 38 artifactoryClient := client.(*ArtifactoryClient) 39 40 if artifactoryClient.nativeClient.Config.BaseURL != "http://artifactory.local:8081/artifactory" { 41 t.Fatalf("Incorrect url was populated") 42 } 43 if artifactoryClient.nativeClient.Config.Username != "test" { 44 t.Fatalf("Incorrect username was populated") 45 } 46 if artifactoryClient.nativeClient.Config.Password != "testpass" { 47 t.Fatalf("Incorrect password was populated") 48 } 49 if artifactoryClient.repo != "terraform-repo" { 50 t.Fatalf("Incorrect repo was populated") 51 } 52 if artifactoryClient.subpath != "myproject" { 53 t.Fatalf("Incorrect subpath was populated") 54 } 55 }