1 import ./make-test-python.nix ({ pkgs, lib, ... }:
3 listenAddress = "127.0.0.1";
5 apiUrl = "http://${listenAddress}:${toString listenPort}";
7 indexJSON = pkgs.writeText "index.json" (builtins.toJSON { inherit uid; });
8 moviesJSON = pkgs.fetchurl {
9 url = "https://github.com/meilisearch/meilisearch/raw/v0.23.1/datasets/movies/movies.json";
10 sha256 = "1r3srld63dpmg9yrmysm6xl175661j5cspi93mk5q2wf8xwn50c5";
14 meta.maintainers = with lib.maintainers; [ Br1ght0ne ];
16 nodes.machine = { ... }: {
17 environment.systemPackages = with pkgs; [ curl jq ];
18 services.meilisearch = {
20 inherit listenAddress listenPort;
29 machine.wait_for_unit("meilisearch")
30 machine.wait_for_open_port(7700)
32 with subtest("check version"):
33 version = json.loads(machine.succeed("curl ${apiUrl}/version"))
34 assert version["pkgVersion"] == "${pkgs.meilisearch.version}"
36 with subtest("create index"):
38 "curl -X POST -H 'Content-Type: application/json' ${apiUrl}/indexes --data @${indexJSON}"
40 indexes = json.loads(machine.succeed("curl ${apiUrl}/indexes"))
41 assert indexes["total"] == 1, "index wasn't created"
43 with subtest("add documents"):
44 response = json.loads(
46 "curl -X POST -H 'Content-Type: application/json' ${apiUrl}/indexes/${uid}/documents --data-binary @${moviesJSON}"
49 task_uid = response["taskUid"]
50 machine.wait_until_succeeds(
51 f"curl ${apiUrl}/tasks/{task_uid} | jq -e '.status == \"succeeded\"'"
54 with subtest("search"):
55 response = json.loads(
56 machine.succeed("curl ${apiUrl}/indexes/movies/search?q=hero")
59 assert len(response["hits"]) >= 1, "no results found"