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:
Shubham Sharma 2022-03-12 01:42:06 +05:30 committed by GitHub
parent 0eda01bf38
commit 49e6a97197
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View File

@ -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

View File

@ -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")