Skip to content
This repository has been archived by the owner on Oct 5, 2021. It is now read-only.

Commit

Permalink
Fix test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
prabushi committed Mar 26, 2021
1 parent 78e8ff4 commit b189553
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 29 deletions.
52 changes: 26 additions & 26 deletions test/commands/cli-cmds.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
*/
import * as fs from "fs";
import * as rimraf from "rimraf";
// import * as http from 'http';
import * as http from 'http';
import * as path from 'path';
import { BallerinaProject } from "src/core";
import { runCommand, BALLERINA_COMMANDS } from '../../src/project/cli-cmds/cmd-runner';
import { getBallerinaHome } from '../test-util';
import { getBallerinaHome, killPort } from '../test-util';

const PROJECT_ROOT = path.join(__dirname, '..', '..', '..', 'test', 'data');
const HELLO_PACKAGE_TARGET_PATH = path.join(PROJECT_ROOT, 'helloPackage', 'target');
Expand Down Expand Up @@ -97,30 +97,30 @@ suite("Ballerina Extension CLI Command Tests", () => {
runCommand(PROJECT_ROOT, BALLERINA_CMD, BALLERINA_COMMANDS.BUILD, filePath);
}).timeout(15000);

// test("Test Run - Ballerina project", done => {
// const projectPath = path.join(PROJECT_ROOT, 'helloServicePackage');
// const balProject: BallerinaProject = {
// path: projectPath,
// version: '0.0.1',
// packageName: 'helloserviceproject',
// kind: 'BUILD_PROJECT'
// };
test("Test Run - Ballerina project", done => {
const projectPath = path.join(PROJECT_ROOT, 'helloService9093Package');
const balProject: BallerinaProject = {
path: projectPath,
version: '0.0.1',
packageName: 'helloservice9093project',
kind: 'BUILD_PROJECT'
};

// runCommand(balProject, BALLERINA_CMD, BALLERINA_COMMANDS.RUN, projectPath);
// const response = http.get('http://0.0.0.0:9091/hello/sayHello');
// if (response) {
// done();
// }
// killPort(9091);
// }).timeout(15000);
runCommand(balProject, BALLERINA_CMD, BALLERINA_COMMANDS.RUN, projectPath);
const response = http.get('http://0.0.0.0:9093/hello/sayHello');
if (response) {
done();
}
killPort(9093);
}).timeout(15000);

// test("Test Run - Single file", done => {
// const filePath = path.join(PROJECT_ROOT, 'hello_world_service.bal');
// runCommand(PROJECT_ROOT, BALLERINA_CMD, BALLERINA_COMMANDS.RUN, filePath);
// const response = http.get('http://0.0.0.0:9090/hello/sayHello');
// if (response) {
// done();
// }
// killPort(9090);
// }).timeout(15000);
test("Test Run - Single file", done => {
const filePath = path.join(PROJECT_ROOT, 'hello_world_service_9092.bal');
runCommand(PROJECT_ROOT, BALLERINA_CMD, BALLERINA_COMMANDS.RUN, filePath);
const response = http.get('http://0.0.0.0:9092/hello/sayHello');
if (response) {
done();
}
killPort(9092);
}).timeout(15000);
});
2 changes: 2 additions & 0 deletions test/data/helloService9093Package/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
target/
.vscode/
5 changes: 5 additions & 0 deletions test/data/helloService9093Package/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[package]
org = "wso2"
name = "helloservice9093project"
version = "0.0.1"

14 changes: 14 additions & 0 deletions test/data/helloService9093Package/hello_service.bal
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import ballerina/http;
import ballerina/io;

// By default, Ballerina exposes an HTTP service via HTTP/1.1.
service /hello on new http:Listener(9093) {

// Resource functions are invoked with the HTTP caller and the
// incoming request as arguments.
resource function get sayHello(http:Caller caller, http:Request req) returns error? {
// Send a response back to the caller.
io:println("request received");
check caller->respond("Hello, World!");
}
}
12 changes: 12 additions & 0 deletions test/data/hello_world_service_9092.bal
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import ballerina/http;

// By default, Ballerina exposes an HTTP service via HTTP/1.1.
service /hello on new http:Listener(9092) {

// Resource functions are invoked with the HTTP caller and the
// incoming request as arguments.
resource function get sayHello(http:Caller caller, http:Request req) returns error? {
// Send a response back to the caller.
check caller->respond("Hello, World!");
}
}
4 changes: 1 addition & 3 deletions test/language-server/lang-client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -545,11 +545,9 @@ suite("Language Server Tests", function () {
};

langClient.sendRequest('textDocument/codeAction', actionParam).then((response: any) => {
assert.equal(response.length, 2, 'Invalid number of code actions.');
assert.equal(response.length, 1, 'Invalid number of code actions.');
assert.equal(response[0].title, "Add type cast to assignment", 'Invalid type cast action.');
assert.equal(response[0].kind, "quickfix", "Invalid code action kind - 1st.");
assert.equal(response[1].title, "Change variable 'piValue' type to 'string'", 'Invalid variable change command.');
assert.equal(response[1].kind, "quickfix", "Invalid code action kind - 0th.");
done();
});
});
Expand Down

0 comments on commit b189553

Please sign in to comment.