From 252f9425fc9a5fc8a7e152772b7af67ff7869652 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Wed, 30 Oct 2024 10:48:51 -0400 Subject: Fixes download test * NGINX updated and changed the default error page source code * Look for "404" in the page contents --- tests/test_download.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'tests/test_download.c') diff --git a/tests/test_download.c b/tests/test_download.c index ad8724e..714e614 100644 --- a/tests/test_download.c +++ b/tests/test_download.c @@ -2,15 +2,20 @@ #include "download.h" void test_download() { + enum MATCH_STYLE { + match_begins=0, + match_contains, + }; struct testcase { const char *url; long http_code; + enum MATCH_STYLE style; const char *data; const char *errmsg; }; struct testcase tc[] = { - {.url = "https://ssb.stsci.edu/jhunk/stasis_test/test_download.txt", .http_code = 200L, .data = "It works!\n", .errmsg = NULL}, - {.url = "https://ssb.stsci.edu/jhunk/stasis_test/test_download.broken", .http_code = 404L, .data = "= 0) { STASIS_ASSERT(data != NULL, "data should not be null"); - STASIS_ASSERT(strncmp(data[0], tc[i].data, strlen(tc[i].data)) == 0, "data file does not match the expected contents"); + printf("FILE: %s\nLOCAL: '%s'\nREMOTE: '%s'\n", tc[i].url, data, tc[i].data); + if (tc[i].style == match_begins) { + STASIS_ASSERT(strncmp(data, tc[i].data, strlen(tc[i].data)) == 0, "data file does not begin with the expected contents"); + } else if (tc[i].style == match_contains) { + STASIS_ASSERT(strstr(data, tc[i].data) != NULL, "data file does not contain the expected contents"); + } else { + STASIS_ASSERT(false, "Unrecognized matching mode"); + } } else { STASIS_ASSERT(http_code == -1, "http_code should be -1 on fatal curl error"); STASIS_ASSERT(data == NULL, "data should be NULL on fatal curl error"); -- cgit