diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 95188b5fa..cb0072afd 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,7 +13,7 @@ jobs: fail-fast: false matrix: php-version: ['8.1'] - sdk: [Android11Java8, Android11Java11, Android12Java8, Android12Java11, CLINode14, CLINode16, DartBeta, DartStable, Deno1193, Deno1303, DotNet60, DotNet70, FlutterStable, FlutterBeta, Go112, Go118, KotlinJava8, KotlinJava11, KotlinJava17, Node12, Node14, Node16, PHP74, PHP80, Python38, Python39, Python310, Ruby27, Ruby30, Ruby31, AppleSwift55, Swift55, WebChromium, WebNode] + sdk: [Android11Java8, Android11Java11, Android12Java8, Android12Java11, CLINode16, CLINode18, DartBeta, DartStable, Deno1193, Deno1303, DotNet60, DotNet70, FlutterStable, FlutterBeta, Go112, Go118, KotlinJava8, KotlinJava11, KotlinJava17, Node12, Node14, Node16, PHP74, PHP80, Python38, Python39, Python310, Ruby27, Ruby30, Ruby31, AppleSwift55, Swift55, WebChromium, WebNode] steps: - name: Checkout repository diff --git a/mock-server/app/http.php b/mock-server/app/http.php index 848fb56f5..38cf265a0 100644 --- a/mock-server/app/http.php +++ b/mock-server/app/http.php @@ -72,6 +72,18 @@ ->action(function ($x, $y, $z) { }); +// Version Route for CLI +App::get('/v1/health/version') + ->desc('Get version') + ->groups(['api', 'health']) + ->label('scope', 'public') + ->label('sdk.response.code', Response::STATUS_CODE_OK) + ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) + ->inject('response') + ->action(function (UtopiaSwooleResponse $response) { + $response->json([ 'version' => '1.0.0' ]); + }); + App::post('/v1/mock/tests/foo') ->desc('Post Foo') ->groups(['mock']) diff --git a/tests/CLINode14Test.php b/tests/CLINode18Test.php similarity index 94% rename from tests/CLINode14Test.php rename to tests/CLINode18Test.php index 2447746a5..b4f58c9c0 100644 --- a/tests/CLINode14Test.php +++ b/tests/CLINode18Test.php @@ -5,7 +5,7 @@ use Appwrite\SDK\Language; use Appwrite\SDK\Language\CLI; -class CLINode14Test extends Base +class CLINode18Test extends Base { protected string $sdkName = 'cli'; protected string $sdkPlatform = 'server'; @@ -15,11 +15,11 @@ class CLINode14Test extends Base protected string $language = 'cli'; protected string $class = 'Appwrite\SDK\Language\CLI'; protected array $build = [ - 'docker run --rm -v $(pwd):/app -w /app/tests/sdks/cli node:16-alpine npm install', + 'docker run --rm -v $(pwd):/app -w /app/tests/sdks/cli node:18-alpine npm install', 'cp tests/languages/cli/test.js tests/sdks/cli/test.js' ]; protected string $command = - 'docker run --network="mockapi" --rm -v $(pwd):/app -w /app/tests/sdks/cli node:14-alpine node test.js'; + 'docker run --network="mockapi" --rm -v $(pwd):/app -w /app/tests/sdks/cli node:18-alpine node test.js'; protected array $expectedOutput = [ ...Base::FOO_RESPONSES, diff --git a/tests/languages/cli/test.js b/tests/languages/cli/test.js index 9ea5de6e5..b6e1d08b1 100644 --- a/tests/languages/cli/test.js +++ b/tests/languages/cli/test.js @@ -1,57 +1,96 @@ -const { exec, execSync } = require('child_process'); +const { exec, execSync } = require("child_process"); -execSync("node index client --endpoint 'https://qa.appwrite.org/v1' --projectId console --key=35y3h5h345 --selfSigned true", { stdio: 'inherit' }); +execSync( + "node index client --endpoint 'http://mockapi/v1' --projectId console --key=35y3h5h345 --selfSigned true", + { stdio: "inherit" } +); var output; -console.log('\nTest Started'); +console.log("\nTest Started"); // Foo -output = execSync("node index foo get --x string --y 123 --z string in array", { stdio: 'pipe'}).toString(); -console.log(output.split('\n')[0].split(" : ")[1]); - -output = execSync("node index foo post --x string --y 123 --z string in array", { stdio: 'pipe'}).toString(); -console.log(output.split('\n')[0].split(" : ")[1]); - -output = execSync("node index foo put --x string --y 123 --z string in array", { stdio: 'pipe'}).toString(); -console.log(output.split('\n')[0].split(" : ")[1]); - -output = execSync("node index foo patch --x string --y 123 --z string in array", { stdio: 'pipe'}).toString(); -console.log(output.split('\n')[0].split(" : ")[1]); - -output = execSync("node index foo delete --x string --y 123 --z string in array", { stdio: 'pipe'}).toString(); -console.log(output.split('\n')[0].split(" : ")[1]); +output = execSync( + "node index foo get --x string --y 123 --z string in array", + { stdio: "pipe" } +).toString(); +console.log(output.split("\n")[0].split(" : ")[1]); + +output = execSync( + "node index foo post --x string --y 123 --z string in array", + { stdio: "pipe" } +).toString(); +console.log(output.split("\n")[0].split(" : ")[1]); + +output = execSync( + "node index foo put --x string --y 123 --z string in array", + { stdio: "pipe" } +).toString(); +console.log(output.split("\n")[0].split(" : ")[1]); + +output = execSync( + "node index foo patch --x string --y 123 --z string in array", + { stdio: "pipe" } +).toString(); +console.log(output.split("\n")[0].split(" : ")[1]); + +output = execSync( + "node index foo delete --x string --y 123 --z string in array", + { stdio: "pipe" } +).toString(); +console.log(output.split("\n")[0].split(" : ")[1]); // Bar -output = execSync("node index bar get --required string --xdefault 123 --z string in array", { stdio: 'pipe'}).toString(); -console.log(output.split('\n')[0].split(" : ")[1]); - -output = execSync("node index bar post --required string --xdefault 123 --z string in array", { stdio: 'pipe'}).toString(); -console.log(output.split('\n')[0].split(" : ")[1]); - -output = execSync("node index bar put --required string --xdefault 123 --z string in array", { stdio: 'pipe'}).toString(); -console.log(output.split('\n')[0].split(" : ")[1]); - -output = execSync("node index bar patch --required string --xdefault 123 --z string in array", { stdio: 'pipe'}).toString(); -console.log(output.split('\n')[0].split(" : ")[1]); - -output = execSync("node index bar delete --required string --xdefault 123 --z string in array", { stdio: 'pipe'}).toString(); -console.log(output.split('\n')[0].split(" : ")[1]); +output = execSync( + "node index bar get --required string --xdefault 123 --z string in array", + { stdio: "pipe" } +).toString(); +console.log(output.split("\n")[0].split(" : ")[1]); + +output = execSync( + "node index bar post --required string --xdefault 123 --z string in array", + { stdio: "pipe" } +).toString(); +console.log(output.split("\n")[0].split(" : ")[1]); + +output = execSync( + "node index bar put --required string --xdefault 123 --z string in array", + { stdio: "pipe" } +).toString(); +console.log(output.split("\n")[0].split(" : ")[1]); + +output = execSync( + "node index bar patch --required string --xdefault 123 --z string in array", + { stdio: "pipe" } +).toString(); +console.log(output.split("\n")[0].split(" : ")[1]); + +output = execSync( + "node index bar delete --required string --xdefault 123 --z string in array", + { stdio: "pipe" } +).toString(); +console.log(output.split("\n")[0].split(" : ")[1]); // General -output = execSync("node index general redirect", { stdio: 'pipe'}).toString(); -console.log(output.split('\n')[0].split(" : ")[1]); +output = execSync("node index general redirect", { stdio: "pipe" }).toString(); +console.log(output.split("\n")[0].split(" : ")[1]); -output = execSync("node index general upload --x string --y 123 --z string in array --file ../../resources/file.png", { stdio: 'pipe'}).toString(); -console.log(output.split('\n')[0].split(" : ")[1]); +output = execSync( + "node index general upload --x string --y 123 --z string in array --file ../../resources/file.png", + { stdio: "pipe" } +).toString(); +console.log(output.split("\n")[0].split(" : ")[1]); -output = execSync("node index general upload --x string --y 123 --z string in array --file ../../resources/large_file.mp4", { stdio: 'pipe'}).toString(); -console.log(output.split('\n')[0].split(" : ")[1]); +output = execSync( + "node index general upload --x string --y 123 --z string in array --file ../../resources/large_file.mp4", + { stdio: "pipe" } +).toString(); +console.log(output.split("\n")[0].split(" : ")[1]); // Skip extra tests for CLI -console.log('POST:/v1/mock/tests/general/upload:passed') -console.log('POST:/v1/mock/tests/general/upload:passed') +console.log("POST:/v1/mock/tests/general/upload:passed"); +console.log("POST:/v1/mock/tests/general/upload:passed"); -execSync("node index general empty", { stdio: 'pipe'}); +execSync("node index general empty", { stdio: "pipe" }); -output = execSync("node index general headers", { stdio: 'pipe'}).toString(); -console.log(output.split('\n')[0].split(" : ")[1]); \ No newline at end of file +output = execSync("node index general headers", { stdio: "pipe" }).toString(); +console.log(output.split("\n")[0].split(" : ")[1]);