From 1d7a57cfd9bf40658e2f35c13146d746a1011020 Mon Sep 17 00:00:00 2001 From: Cole Helbling Date: Thu, 17 Aug 2023 13:40:57 -0700 Subject: [PATCH] libexpr/tests: test that parseFlakeRef doesn't percent-encode twice --- src/libexpr/tests/flakeref.cc | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/libexpr/tests/flakeref.cc diff --git a/src/libexpr/tests/flakeref.cc b/src/libexpr/tests/flakeref.cc new file mode 100644 index 000000000..2b7809b93 --- /dev/null +++ b/src/libexpr/tests/flakeref.cc @@ -0,0 +1,22 @@ +#include + +#include "flake/flakeref.hh" + +namespace nix { + +/* ----------- tests for flake/flakeref.hh --------------------------------------------------*/ + + /* ---------------------------------------------------------------------------- + * to_string + * --------------------------------------------------------------------------*/ + + TEST(to_string, doesntReencodeUrl) { + auto s = "http://localhost:8181/test/+3d.tar.gz"; + auto flakeref = parseFlakeRef(s); + auto parsed = flakeref.to_string(); + auto expected = "http://localhost:8181/test/%2B3d.tar.gz"; + + ASSERT_EQ(parsed, expected); + } + +}