mirror of https://github.com/dapr/cli.git
Handle HTTP status checks in invoke (#910)
* Use status code check after invoke Signed-off-by: Shubham Sharma <shubhash@microsoft.com> * Add e2e test Signed-off-by: Shubham Sharma <shubhash@microsoft.com>
This commit is contained in:
parent
0eda01bf38
commit
49e6a97197
|
@ -68,6 +68,10 @@ func makeEndpoint(lo ListOutput, method string) string {
|
|||
}
|
||||
|
||||
func handleResponse(response *http.Response) (string, error) {
|
||||
if response.StatusCode < 200 || response.StatusCode >= 400 {
|
||||
return "", fmt.Errorf("%s", response.Status)
|
||||
}
|
||||
|
||||
rb, err := ioutil.ReadAll(response.Body)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
|
|
@ -651,6 +651,13 @@ func testInvoke(t *testing.T) {
|
|||
assert.Contains(t, output, "error invoking app invoke_e2e_2: app ID invoke_e2e_2 not found")
|
||||
})
|
||||
|
||||
t.Run(fmt.Sprintf("invoke with an invalid method name %s", path), func(t *testing.T) {
|
||||
output, err := spawn.Command(daprPath, "invoke", "--app-id", "invoke_e2e", "--unix-domain-socket", path, "--method", "test2")
|
||||
t.Log(output)
|
||||
assert.Error(t, err, "method test2 should not exist")
|
||||
assert.Contains(t, output, "error invoking app invoke_e2e: 404 Not Found")
|
||||
})
|
||||
|
||||
output, err := spawn.Command(getDaprPath(), "stop", "--app-id", "invoke_e2e")
|
||||
t.Log(output)
|
||||
require.NoError(t, err, "dapr stop failed")
|
||||
|
|
Loading…
Reference in New Issue