Skip to content

Commit cac0961

Browse files
authored
fix(dynamodb-local): fix check on inMemory to allow setting dbPath (#647)
What changed? Adjusted the check in the dynamodb-local service so that the inMemory flag and dbPath setting are evaluated correctly. Added appropriate test(s) to cover both modes and ensure dbPath can be set when inMemory = false.
1 parent 1831807 commit cac0961

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

nix/services/dynamodb-local.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
'';
3535
apply =
3636
v:
37-
lib.throwIf (config.dbPath != null) ''
38-
You can't specify both -dbPath and -inMemory at once.
37+
lib.throwIf (config.dbPath != null && v) ''
38+
You can't specify both dbPath and set inMemory to true at once.
3939
''
4040
v;
4141
};

nix/services/dynamodb-local_test.nix

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,16 @@
77
inMemory = true;
88
};
99

10+
services.dynamodb-local."dynamodb2" = {
11+
enable = true;
12+
port = 8001;
13+
dbPath = "/tmp/dynamodb2";
14+
};
15+
1016
settings.processes.test =
1117
let
12-
cfg = config.services.dynamodb-local."dynamodb1";
18+
cfg1 = config.services.dynamodb-local."dynamodb1";
19+
cfg2 = config.services.dynamodb-local."dynamodb2";
1320
in
1421
{
1522
command = pkgs.writeShellApplication {
@@ -21,10 +28,13 @@
2128
AWS_DEFAULT_REGION = "us-east-1";
2229
};
2330
text = ''
24-
aws dynamodb list-tables --endpoint-url "http://127.0.0.1:${toString cfg.port}" \
31+
aws dynamodb list-tables --endpoint-url "http://127.0.0.1:${toString cfg1.port}" \
32+
| jq '.TableNames'
33+
aws dynamodb list-tables --endpoint-url "http://127.0.0.1:${toString cfg2.port}" \
2534
| jq '.TableNames'
2635
'';
2736
};
2837
depends_on."dynamodb1".condition = "process_healthy";
38+
depends_on."dynamodb2".condition = "process_healthy";
2939
};
3040
}

0 commit comments

Comments
 (0)