Skip to content

Commit 822914e

Browse files
authored
Delete and inspect test (#51)
* delete and inspect test added * package undefined issue solved * echo removed * delete test removed * auto deploy test fixed * ci fixed * Revet to old package-lock.json * Tabs for indentation * Indentation corrected
1 parent d26824f commit 822914e

File tree

3 files changed

+45
-2
lines changed

3 files changed

+45
-2
lines changed

src/controller/inspect.ts

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ export const inspect = (_req: Request, res: Response): Response => {
88
for (const application of Object.values(Applications)) {
99
// Check if the application is deployed
1010
if (application.deployment) {
11+
// Ensure packages is not undefined or null
12+
if (!application.deployment.packages) {
13+
throw new Error('Packages is undefined or null');
14+
}
1115
deployments.push(application.deployment);
1216
}
1317
}

src/worker/index.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable */
22

3-
import { Deployment, MetaCallJSON } from '@metacall/protocol';
3+
import { Deployment, LanguageId, MetaCallJSON } from '@metacall/protocol';
44
import { findFilesPath, findMetaCallJsons } from '@metacall/protocol/package';
55
import { promises as fs } from 'fs';
66
import {
@@ -54,7 +54,8 @@ const loadDeployment = (
5454
throw new Error(`language_id not found in ${path}`);
5555
}
5656

57-
deployment.packages = inspect[json.language_id][path];
57+
deployment.packages[json.language_id as LanguageId] =
58+
inspect[json.language_id];
5859

5960
// Store the functions
6061
Object.keys(exports).forEach(func => {

test/test.sh

+38
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,41 @@ pushd data/$app
5353
[[ $(curl -s $url/number) = 100 ]] || exit 1
5454
[[ $(curl -s $url/text) = '"asd"' ]] || exit 1
5555
popd
56+
57+
# Test inspect
58+
echo "Testing inspect functionality."
59+
60+
# Inspect the deployed projects
61+
inspect_response=$(curl -s $BASE_URL/api/inspect)
62+
63+
# Verify inspection
64+
if [[ $inspect_response != *"$prefix"* ]]; then
65+
echo "Inspection test failed."
66+
exit 1
67+
fi
68+
69+
# Verify packages are included in the response
70+
if [[ $inspect_response != *"packages"* ]]; then
71+
echo "packages not found in inspection response."
72+
exit 1
73+
fi
74+
75+
echo "Inspection test passed."
76+
77+
# Test delete only if we are not testing startup deployments
78+
if [[ "${TEST_FAAS_STARTUP_DEPLOY}" == "true" ]]; then
79+
echo "Testing delete functionality."
80+
81+
# Delete the deployed project
82+
curl -X POST -H "Content-Type: application/json" -d '{"suffix":"python-base-app","prefix":"'"$prefix"'","version":"v1"}' $BASE_URL/api/deploy/delete
83+
84+
# Verify deletion
85+
if [[ $(curl -s -o /dev/null -w "%{http_code}" $BASE_URL/$prefix/$app/v1/call/number) != "404" ]]; then
86+
echo "Deletion test failed."
87+
exit 1
88+
fi
89+
90+
echo "Deletion test passed."
91+
fi
92+
93+
echo "Integration tests passed without errors."

0 commit comments

Comments
 (0)