aboutsummaryrefslogtreecommitdiff
path: root/tests/unit
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/libstore/filetransfer.cc8
-rw-r--r--tests/unit/libutil/compression.cc3
-rw-r--r--tests/unit/meson.build6
3 files changed, 15 insertions, 2 deletions
diff --git a/tests/unit/libstore/filetransfer.cc b/tests/unit/libstore/filetransfer.cc
index 71e7392fc..fd4d326f0 100644
--- a/tests/unit/libstore/filetransfer.cc
+++ b/tests/unit/libstore/filetransfer.cc
@@ -150,6 +150,14 @@ TEST(FileTransfer, exceptionAbortsDownload)
}
}
+TEST(FileTransfer, exceptionAbortsRead)
+{
+ auto [port, srv] = serveHTTP("200 ok", "content-length: 0\r\n", [] { return ""; });
+ auto ft = makeFileTransfer();
+ char buf[10] = "";
+ ASSERT_THROW(ft->download(FileTransferRequest(fmt("http://[::1]:%d/index", port)))->read(buf, 10), EndOfFile);
+}
+
TEST(FileTransfer, NOT_ON_DARWIN(reportsSetupErrors))
{
auto [port, srv] = serveHTTP("404 not found", "", [] { return ""; });
diff --git a/tests/unit/libutil/compression.cc b/tests/unit/libutil/compression.cc
index 8d181f53d..6dd8c96df 100644
--- a/tests/unit/libutil/compression.cc
+++ b/tests/unit/libutil/compression.cc
@@ -1,4 +1,5 @@
#include "compression.hh"
+#include <cstddef>
#include <gtest/gtest.h>
namespace nix {
@@ -147,7 +148,7 @@ TEST_P(PerTypeNonNullCompressionTest, truncatedValidInput)
/* n.b. This also tests zero-length input, which is also invalid.
* As of the writing of this comment, it returns empty output, but is
* allowed to throw a compression error instead. */
- for (int i = 0; i < compressed.length(); ++i) {
+ for (size_t i = 0u; i < compressed.length(); ++i) {
auto newCompressed = compressed.substr(compressed.length() - i);
try {
decompress(method, newCompressed);
diff --git a/tests/unit/meson.build b/tests/unit/meson.build
index c831ba379..9db619c5d 100644
--- a/tests/unit/meson.build
+++ b/tests/unit/meson.build
@@ -12,7 +12,11 @@
# It's only ~200 lines; better to just refactor the tests themselves which we'll want to do anyway.
default_test_env = {
- 'ASAN_OPTIONS': 'detect_leaks=0:halt_on_error=1:abort_on_error=1:print_summary=1:dump_instruction_bytes=1'
+ 'ASAN_OPTIONS': 'detect_leaks=0:halt_on_error=1:abort_on_error=1:print_summary=1:dump_instruction_bytes=1',
+ # Prevents loading global configuration file in /etc/nix/nix.conf in tests 😱
+ 'NIX_CONF_DIR': '/var/empty',
+ # Prevent loading user configuration files in tests
+ 'NIX_USER_CONF_FILES': '',
}
libutil_test_support_sources = files(