Skip to content

Commit 1839be4

Browse files
committed
chore: updates test files
1 parent 65f0c08 commit 1839be4

File tree

5 files changed

+55
-11
lines changed

5 files changed

+55
-11
lines changed

cfn-resources/custom-db-role/test/cfn-test-create-inputs.sh

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ rm -rf inputs
1919
mkdir inputs
2020

2121
projectName="${1}"
22+
MONGODB_ATLAS_PROFILE=${MONGODB_ATLAS_PROFILE:-"default"}
2223
projectId=$(atlas projects list --output json | jq --arg NAME "${projectName}" -r '.results[] | select(.name==$NAME) | .id')
2324
if [ -z "$projectId" ]; then
2425
projectId=$(atlas projects create "${projectName}" --output=json | jq -r '.id')
@@ -30,10 +31,12 @@ fi
3031

3132
echo "Created project \"${projectName}\" with id: ${projectId}"
3233

33-
jq --arg projectId "$projectId" \
34-
'.ProjectId?|=$projectId ' \
35-
"$(dirname "$0")/inputs_1_create.template.json" >"inputs/inputs_1_create.json"
36-
37-
jq --arg projectId "$projectId" \
38-
'.ProjectId?|=$projectId ' \
39-
"$(dirname "$0")/inputs_1_update.template.json" >"inputs/inputs_1_update.json"
34+
cd "$(dirname "$0")" || exit
35+
WORDTOREMOVE="template."
36+
for inputFile in inputs_*; do
37+
outputFile=${inputFile//$WORDTOREMOVE/}
38+
jq --arg ProjectId "$projectId" --arg Profile "${MONGODB_ATLAS_PROFILE}" \
39+
'.ProjectId?|=$ProjectId | .Profile?|=$Profile' \
40+
"$inputFile" >"../inputs/$outputFile"
41+
done
42+
cd ..

cfn-resources/custom-db-role/test/inputs_1_create.template.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"ProjectId": "",
2+
"ProjectId": "${MONGODB_ATLAS_PROJECT_ID}",
33
"Actions": [
44
{
55
"Action": "FIND",
@@ -12,5 +12,5 @@
1212
}
1313
],
1414
"RoleName": "testcreate",
15-
"Profile": "default"
15+
"Profile": "${MONGODB_ATLAS_PROFILE}"
1616
}
Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"ProjectId": "",
2+
"ProjectId": "${MONGODB_ATLAS_PROJECT_ID}",
33
"Actions": [
44
{
55
"Action": "FIND",
@@ -9,8 +9,17 @@
99
"DB": "sample_airbnb"
1010
}
1111
]
12+
},
13+
{
14+
"Action": "INSERT",
15+
"Resources": [
16+
{
17+
"Collection": "listingsAndReviews",
18+
"DB": "sample_airbnb"
19+
}
20+
]
1221
}
1322
],
1423
"RoleName": "testcreate",
15-
"Profile": "default"
24+
"Profile": "${MONGODB_ATLAS_PROFILE}"
1625
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"ProjectId": "${MONGODB_ATLAS_PROJECT_ID}",
3+
"Actions": [
4+
{
5+
"Action": "FIND",
6+
"Resources": [
7+
{
8+
"Collection": "",
9+
"DB": ""
10+
}
11+
]
12+
}
13+
],
14+
"RoleName": "testcreate-cfn-empty-db",
15+
"Profile": "${MONGODB_ATLAS_PROFILE}"
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"ProjectId": "${MONGODB_ATLAS_PROJECT_ID}",
3+
"Actions": [
4+
{
5+
"Action": "INSERT",
6+
"Resources": [
7+
{
8+
"Collection": "",
9+
"DB": ""
10+
}
11+
]
12+
}
13+
],
14+
"RoleName": "testcreate-cfn-empty-db",
15+
"Profile": "${MONGODB_ATLAS_PROFILE}"
16+
}

0 commit comments

Comments
 (0)