From 0a5abf6652edca33c5f6cde213b87d7a71cf4779 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Sat, 13 Jan 2024 18:36:51 +0200 Subject: [PATCH] test with `nix build <...>` --- Makefile | 7 +++++++ app/e11sync/urls.py | 4 +++- flake.nix | 17 ++++++++++++----- 3 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..05e183a --- /dev/null +++ b/Makefile @@ -0,0 +1,7 @@ +.PHONY: check +test: + nix build .#e11sync-gunicorn.tests.simple -L + +.PHONY: gunicorn +gunicorn: + nix run .#e11sync-gunicorn diff --git a/app/e11sync/urls.py b/app/e11sync/urls.py index 5e21633..951d390 100644 --- a/app/e11sync/urls.py +++ b/app/e11sync/urls.py @@ -17,9 +17,11 @@ Including another URLconf from django.contrib import admin from django.urls import include, path +from django.conf import settings urlpatterns = [ path('admin/', admin.site.urls), - path("__debug__/", include("debug_toolbar.urls")), + ] + [ + path("__debug__/", include("debug_toolbar.urls"))] if settings.DEBUG else [] + [ path('', include('signup.urls')), ] diff --git a/flake.nix b/flake.nix index 3264109..e76a5d9 100644 --- a/flake.nix +++ b/flake.nix @@ -88,13 +88,20 @@ --set E11SYNC_DEBUG "" \ --set E11SYNC_COMPRESS_OFFLINE 1 \ --set GEOIP_PATH "${geoip}" \ - --add-flags e11sync.wsgi \ - --add-flags --bind=127.0.0.1:${toString gunicornPort} + --add-flags --bind=127.0.0.1:${toString gunicornPort} \ + --add-flags e11sync.wsgi ''; passthru.tests = { - simple = pkgs.runCommand {} "e11sync-test" '' - exit 1; - ''; + simple = + pkgs.runCommand "e11sync-test" { + src = self; + buildInputs = runtimeDeps ++ buildDeps; + } '' + mkdir -p $out + cd ${self}/app + export GEOIP_PATH="${geoip}" + ${pkgs.python3}/bin/python3 ./manage.py test + ''; }; };