forked from hashicorp/terraform
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathartifactory_test.go
More file actions
55 lines (45 loc) · 1.47 KB
/
Copy pathartifactory_test.go
File metadata and controls
55 lines (45 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package remote
import (
"testing"
)
func TestArtifactoryClient_impl(t *testing.T) {
var _ Client = new(ArtifactoryClient)
}
func TestArtifactoryFactory(t *testing.T) {
// This test just instantiates the client. Shouldn't make any actual
// requests nor incur any costs.
config := make(map[string]string)
// Empty config is an error
_, err := artifactoryFactory(config)
if err == nil {
t.Fatalf("Empty config should be error")
}
config["url"] = "http://artifactory.local:8081/artifactory"
config["repo"] = "terraform-repo"
config["subpath"] = "myproject"
// For this test we'll provide the credentials as config. The
// acceptance tests implicitly test passing credentials as
// environment variables.
config["username"] = "test"
config["password"] = "testpass"
client, err := artifactoryFactory(config)
if err != nil {
t.Fatalf("Error for valid config")
}
artifactoryClient := client.(*ArtifactoryClient)
if artifactoryClient.nativeClient.Config.BaseURL != "http://artifactory.local:8081/artifactory" {
t.Fatalf("Incorrect url was populated")
}
if artifactoryClient.nativeClient.Config.Username != "test" {
t.Fatalf("Incorrect username was populated")
}
if artifactoryClient.nativeClient.Config.Password != "testpass" {
t.Fatalf("Incorrect password was populated")
}
if artifactoryClient.repo != "terraform-repo" {
t.Fatalf("Incorrect repo was populated")
}
if artifactoryClient.subpath != "myproject" {
t.Fatalf("Incorrect subpath was populated")
}
}