Skip to content

Commit

Permalink
Delete and inspect test (#51)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
HeeManSu authored Jun 7, 2024
1 parent d26824f commit 822914e
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/controller/inspect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ export const inspect = (_req: Request, res: Response): Response => {
for (const application of Object.values(Applications)) {
// Check if the application is deployed
if (application.deployment) {
// Ensure packages is not undefined or null
if (!application.deployment.packages) {
throw new Error('Packages is undefined or null');
}
deployments.push(application.deployment);
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/worker/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable */

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

deployment.packages = inspect[json.language_id][path];
deployment.packages[json.language_id as LanguageId] =
inspect[json.language_id];

// Store the functions
Object.keys(exports).forEach(func => {
Expand Down
38 changes: 38 additions & 0 deletions test/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,41 @@ pushd data/$app
[[ $(curl -s $url/number) = 100 ]] || exit 1
[[ $(curl -s $url/text) = '"asd"' ]] || exit 1
popd

# Test inspect
echo "Testing inspect functionality."

# Inspect the deployed projects
inspect_response=$(curl -s $BASE_URL/api/inspect)

# Verify inspection
if [[ $inspect_response != *"$prefix"* ]]; then
echo "Inspection test failed."
exit 1
fi

# Verify packages are included in the response
if [[ $inspect_response != *"packages"* ]]; then
echo "packages not found in inspection response."
exit 1
fi

echo "Inspection test passed."

# Test delete only if we are not testing startup deployments
if [[ "${TEST_FAAS_STARTUP_DEPLOY}" == "true" ]]; then
echo "Testing delete functionality."

# Delete the deployed project
curl -X POST -H "Content-Type: application/json" -d '{"suffix":"python-base-app","prefix":"'"$prefix"'","version":"v1"}' $BASE_URL/api/deploy/delete

# Verify deletion
if [[ $(curl -s -o /dev/null -w "%{http_code}" $BASE_URL/$prefix/$app/v1/call/number) != "404" ]]; then
echo "Deletion test failed."
exit 1
fi

echo "Deletion test passed."
fi

echo "Integration tests passed without errors."

0 comments on commit 822914e

Please sign in to comment.