MCPcopy
hub / github.com/istio/istio / Test_command_do

Function Test_command_do

pilot/pkg/request/command_test.go:70–155  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

68}
69
70func Test_command_do(t *testing.T) {
71 tests := []struct {
72 name string
73 method string
74 path string
75 body string
76 pilotStates []pilotStubState
77 pilotNotReachable bool
78 wantError bool
79 }{
80 {
81 name: "makes a request using passed method, url and body",
82 method: "POST",
83 path: "/want/path",
84 body: "body",
85 pilotStates: []pilotStubState{
86 {StatusCode: 200, Response: "fine", wantMethod: "POST", wantPath: "/want/path", wantBody: []byte("body")},
87 },
88 },
89 {
90 name: "adds / prefix to path if required",
91 method: "POST",
92 path: "want/path",
93 body: "body",
94 pilotStates: []pilotStubState{
95 {StatusCode: 200, Response: "fine", wantMethod: "POST", wantPath: "/want/path", wantBody: []byte("body")},
96 },
97 },
98 {
99 name: "handles empty string body in args",
100 method: "GET",
101 path: "/want/path",
102 body: "",
103 pilotStates: []pilotStubState{
104 {StatusCode: 200, Response: "fine", wantMethod: "GET", wantPath: "/want/path", wantBody: nil},
105 },
106 },
107 {
108 name: "doesn't error on 404",
109 method: "GET",
110 path: "/want/path",
111 body: "",
112 pilotStates: []pilotStubState{
113 {StatusCode: 404, Response: "not-found", wantMethod: "GET", wantPath: "/want/path", wantBody: nil},
114 },
115 },
116 {
117 name: "errors if Pilot is unreachable",
118 method: "GET",
119 path: "/want/path",
120 pilotNotReachable: true,
121 wantError: true,
122 },
123 {
124 name: "errors if Pilot responds with a non success status",
125 method: "GET",
126 path: "/not/wanted/path",
127 body: "",

Callers

nothing calls this directly

Calls 3

DoMethod · 0.95
RunMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…