From 19e4234f4cb2ac70d9e8edfb99603ea65ba362ab Mon Sep 17 00:00:00 2001 From: FliegendeWurst <2012gdwu+github@posteo.de> Date: Fri, 27 May 2022 13:59:04 +0200 Subject: [PATCH] nixos/tests/meilisearch: fix curl invocation Also replace the movies dataset with a direct download as it is not present in newer meilisearch versions. Link the NixOS test to the package. --- nixos/tests/meilisearch.nix | 11 ++++++----- pkgs/servers/search/meilisearch/default.nix | 4 ++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/nixos/tests/meilisearch.nix b/nixos/tests/meilisearch.nix index 9f54aa97d6ad..05109a944bc4 100644 --- a/nixos/tests/meilisearch.nix +++ b/nixos/tests/meilisearch.nix @@ -5,9 +5,10 @@ import ./make-test-python.nix ({ pkgs, lib, ... }: apiUrl = "http://${listenAddress}:${toString listenPort}"; uid = "movies"; indexJSON = pkgs.writeText "index.json" (builtins.toJSON { inherit uid; }); - moviesJSON = pkgs.runCommand "movies.json" {} '' - sed -n '1,5p;$p' ${pkgs.meilisearch.src}/datasets/movies/movies.json > $out - ''; + moviesJSON = pkgs.fetchurl { + url = "https://github.com/meilisearch/meilisearch/raw/v0.23.1/datasets/movies/movies.json"; + sha256 = "1r3srld63dpmg9yrmysm6xl175661j5cspi93mk5q2wf8xwn50c5"; + }; in { name = "meilisearch"; meta.maintainers = with lib.maintainers; [ Br1ght0ne ]; @@ -34,7 +35,7 @@ import ./make-test-python.nix ({ pkgs, lib, ... }: with subtest("create index"): machine.succeed( - "curl -XPOST ${apiUrl}/indexes --data @${indexJSON}" + "curl -XPOST --header 'Content-Type: application/json' ${apiUrl}/indexes --data @${indexJSON}" ) indexes = json.loads(machine.succeed("curl ${apiUrl}/indexes")) assert len(indexes) == 1, "index wasn't created" @@ -42,7 +43,7 @@ import ./make-test-python.nix ({ pkgs, lib, ... }: with subtest("add documents"): response = json.loads( machine.succeed( - "curl -XPOST ${apiUrl}/indexes/${uid}/documents --data @${moviesJSON}" + "curl -XPOST --header 'Content-Type: application/json' ${apiUrl}/indexes/${uid}/documents --data @${moviesJSON}" ) ) update_id = response["updateId"] diff --git a/pkgs/servers/search/meilisearch/default.nix b/pkgs/servers/search/meilisearch/default.nix index 9165a4713d4e..d188f926f9c2 100644 --- a/pkgs/servers/search/meilisearch/default.nix +++ b/pkgs/servers/search/meilisearch/default.nix @@ -5,6 +5,7 @@ , Security , DiskArbitration , Foundation +, nixosTests }: let version = "0.23.1"; @@ -25,6 +26,9 @@ rustPlatform.buildRustPackage { ]; cargoSha256 = "sha256-dz+1IQZRSeMEagI2dnOtR3A8prg4UZ2Om0pd1BUhuhE="; buildInputs = lib.optionals stdenv.isDarwin [ Security DiskArbitration Foundation ]; + passthru.tests = { + meilisearch = nixosTests.meilisearch; + }; meta = with lib; { description = "Powerful, fast, and an easy to use search engine "; homepage = "https://docs.meilisearch.com/";