-
Notifications
You must be signed in to change notification settings - Fork 1
/
config_test.go
43 lines (40 loc) · 1.32 KB
/
config_test.go
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
package elementalconductor
import (
"encoding/xml"
"net/http"
"reflect"
"testing"
)
func TestGetCloudConfig(t *testing.T) {
data := `<?xml version="1.0" encoding="UTF-8"?>
<cloud_config>
<authorized_node_count>500</authorized_node_count>
<max_cluster_size>30</max_cluster_size>
<min_cluster_size>4</min_cluster_size>
<worker_variant>production_server_cloud</worker_variant>
</cloud_config>`
server, requests := startServer(http.StatusOK, data)
defer server.Close()
client := NewClient(server.URL, "myuser", "secret-key", 45, "aws-access-key", "aws-secret-key", "destination")
config, err := client.GetCloudConfig()
if err != nil {
t.Fatal(err)
}
expectedConfig := CloudConfig{
XMLName: xml.Name{Local: "cloud_config"},
AuthorizedNodeCount: 500,
MaxNodes: 30,
MinNodes: 4,
WorkerVariant: "production_server_cloud",
}
if !reflect.DeepEqual(*config, expectedConfig) {
t.Errorf("wrong config returned\nwant %#v\ngot %#v", expectedConfig, *config)
}
fakeReq := <-requests
if fakeReq.req.Method != http.MethodGet {
t.Errorf("wrong http method\nwant %q\ngot %q", http.MethodGet, fakeReq.req.Method)
}
if expectedPath := "/api/config/cloud"; fakeReq.req.URL.Path != expectedPath {
t.Errorf("wrong request path\nwant %q\ngot %q", expectedPath, fakeReq.req.URL.Path)
}
}