1 # This test start mongodb, runs a query using mongo shell
3 import ./make-test-python.nix ({ pkgs, ... }:
5 testQuery = pkgs.writeScript "nixtest.js" ''
6 db.greetings.insert({ "greeting": "hello" });
7 print(db.greetings.findOne().greeting);
10 runMongoDBTest = pkg: ''
11 node.execute("(rm -rf data || true) && mkdir data")
13 "${pkg}/bin/mongod --fork --logpath logs --dbpath data"
15 node.wait_for_open_port(27017)
17 assert "hello" in node.succeed(
18 "${pkg}/bin/mongo ${testQuery}"
22 "${pkg}/bin/mongod --shutdown --dbpath data"
24 node.wait_for_closed_port(27017)
29 meta = with pkgs.lib.maintainers; {
30 maintainers = [ bluescreen303 offline cstrahan rvl phile314 ];
35 environment.systemPackages = with pkgs; [
49 + runMongoDBTest pkgs.mongodb-3_4
50 + runMongoDBTest pkgs.mongodb-3_6
51 + runMongoDBTest pkgs.mongodb-4_0
52 + runMongoDBTest pkgs.mongodb-4_2
53 + runMongoDBTest pkgs.mongodb-4_4
54 + runMongoDBTest pkgs.mongodb-5_0