MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / newSingleNodeClusterServer

Function newSingleNodeClusterServer

pkg/api/grouped_cluster_test.go:24–82  ·  view source on GitHub ↗
(ticket, csrfToken, nodeName string, cpu float64)

Source from the content-addressed store, hash-verified

22)
23
24func newSingleNodeClusterServer(ticket, csrfToken, nodeName string, cpu float64) *httptest.Server {
25 return httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
26 if r.URL.Path == testAPITicketPath {
27 w.Header().Set("Content-Type", "application/json")
28 _ = json.NewEncoder(w).Encode(map[string]interface{}{
29 "data": map[string]interface{}{
30 "ticket": ticket,
31 "CSRFPreventionToken": csrfToken,
32 },
33 })
34 return
35 }
36 if r.URL.Path == testAPIClusterResourcesPath {
37 w.Header().Set("Content-Type", "application/json")
38 _ = json.NewEncoder(w).Encode(map[string]interface{}{
39 "data": []interface{}{
40 map[string]interface{}{
41 "type": "node",
42 "node": nodeName,
43 "cpu": cpu,
44 "maxcpu": 8,
45 "mem": 1024.0,
46 "maxmem": 2048.0,
47 "disk": 1024.0,
48 "maxdisk": 2048.0,
49 "uptime": 100,
50 },
51 },
52 })
53 return
54 }
55 if r.URL.Path == testAPIClusterStatusPath {
56 w.Header().Set("Content-Type", "application/json")
57 _ = json.NewEncoder(w).Encode(map[string]interface{}{
58 "data": []interface{}{
59 map[string]interface{}{
60 "id": "node/" + nodeName,
61 "name": nodeName,
62 "type": "node",
63 "online": 1,
64 },
65 },
66 })
67 return
68 }
69 if r.URL.Path == testAPINodesPath {
70 w.Header().Set("Content-Type", "application/json")
71 _ = json.NewEncoder(w).Encode(map[string]interface{}{
72 "data": []interface{}{
73 map[string]interface{}{
74 "node": nodeName,
75 "status": "online",
76 },
77 },
78 })
79 return
80 }
81 }))

Calls 2

HeaderMethod · 0.80
SetMethod · 0.65

Tested by

no test coverage detected