Skip to content
This repository has been archived by the owner on Jul 2, 2021. It is now read-only.

Commit

Permalink
Check state
Browse files Browse the repository at this point in the history
  • Loading branch information
Braydon Fuller committed Oct 17, 2017
1 parent b9c3c40 commit 34f3745
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
7 changes: 7 additions & 0 deletions src/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,10 @@ static int upload_file(storj_env_t *env, char *bucket_id, const char *file_path)
progress_cb,
upload_file_complete);

if (!state) {
return 1;
}

sig->data = state;

return state->error_status;
Expand Down Expand Up @@ -514,6 +518,9 @@ static int download_file(storj_env_t *env, char *bucket_id,
file_id, fd, NULL,
progress_cb,
download_file_complete);
if (!state) {
return 1;
}
sig->data = state;

return state->error_status;
Expand Down
20 changes: 13 additions & 7 deletions test/tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -534,10 +534,11 @@ int test_upload()
NULL,
check_store_file_progress,
check_store_file);
assert(state->error_status == 0);
if (!state || state->error_status != 0) {
return 1;
}

// run all queued events

if (uv_run(env->loop, UV_RUN_DEFAULT)) {
return 1;
}
Expand Down Expand Up @@ -580,8 +581,9 @@ int test_upload_cancel()
NULL,
check_store_file_progress,
check_store_file_cancel);
assert(state->error_status == 0);

if (!state || state->error_status != 0) {
return 1;
}

// process the loop one at a time so that we can do other things while
// the loop is processing, such as cancel the download
Expand Down Expand Up @@ -639,9 +641,11 @@ int test_download()
check_resolve_file_progress,
check_resolve_file);

free(download_file);
if (!state || state->error_status != 0) {
return 1;
}

assert(state->error_status == 0);
free(download_file);

if (uv_run(env->loop, UV_RUN_DEFAULT)) {
return 1;
Expand Down Expand Up @@ -679,7 +683,9 @@ int test_download_cancel()
check_resolve_file_progress,
check_resolve_file_cancel);

assert(state->error_status == 0);
if (!state || state->error_status != 0) {
return 1;
}

// process the loop one at a time so that we can do other things while
// the loop is processing, such as cancel the download
Expand Down

0 comments on commit 34f3745

Please sign in to comment.