Skip to content
This repository was archived by the owner on Mar 8, 2020. It is now read-only.

Conversation

@fenglianxu
Copy link
Contributor

set up auto-test framework for client, server and travis #58
Signed-off-by: xufengli xufengli@uk.ibm.com

Signed-off-by: xufengli <xufengli@uk.ibm.com>
@@ -0,0 +1,41 @@
/*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd recommend using a deeper test folder structure here to help you out further down the line:
data/valid
data/valid/cto
data/valid/acl
data/valid/project

data/invalid

etc, etc

Otherwise once you build up a large number of resources, it will be unmaintainable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will add these as needed per our chat.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move the files to data/valid/cto and data/valid/acl now and will update others as needed.

assert.equal(-1, [1, 2, 3].indexOf(0));

// test validation cto
test("activate", () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we're not actually testing activate here, we're testing the ability to open a file using the vscode api

return Promise.reject(err);
});

// let serverOptions: ServerOptions = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to remove comments!

// let serverOptions: ServerOptions = {
// run: { module: serverModule, transport: TransportKind.ipc }
// }
console.log('is activate called?');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to remove console logging

workspace.openTextDocument(uri).then((document) =>{

let text = document.getText();
console.log('text = ' + text);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should not have console logging in the test output, as this will clutter the test file output

// The module 'assert' provides assertion methods from node
import * as assert from 'assert';

// You can import and use all API from the 'vscode' module
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably don't want this generic template text either

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nklincoln I have updated files per your comments. can you review it again please?

it("validateCtoModelFile", () => {

let originatingFileName: string = "./test/data/test.cto";
console.log('is server called?');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no console logging in delivered test code as it clutters the logs - use asserts



// test validation cto
it("validateCtoModelFile", () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All mocha tests should follow a specific format if using a 'describe' framework, as shown here: https://mochajs.org/

This is so that the actual test intention is clear to a third party


let originatingFileName: string = "./test/data/test.cto";
console.log('is server called?');
// server.validateCtoModelFile( originatingFileName);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be commented out?

"nyc": {
"exclude": [
"coverage/**",
"out/**",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these don't exist in the vscode repository ... why are they here?

@fenglianxu fenglianxu force-pushed the test-58 branch 2 times, most recently from 1bf0046 to 9875d77 Compare January 28, 2018 17:02
@fenglianxu fenglianxu self-assigned this Jan 28, 2018
@fenglianxu fenglianxu force-pushed the test-58 branch 5 times, most recently from c76e979 to eb9de93 Compare January 29, 2018 15:29
nklincoln
nklincoln previously approved these changes Jan 29, 2018
Copy link
Contributor

@nklincoln nklincoln left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some minor changes required, but looks good 👍

//Note: if the command is launched from the keyboard shortcut or the command palette,
//we will not have any arguments passed in so cannot get the filename to use in the diagram.
// create a title from the event info
let diagramTitle = 'Business Network Definition'; // ensible default
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

's' missing in sensible

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all updated now


}, (err) => {
assert.ok(false, `error in OpenTextDocument ${err}`);
return Promise.reject(err);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line is redundant as it will fail the test based on the assert above it


}, (err) => {
assert.ok(false, `error in OpenTextDocument ${err}`);
return Promise.reject(err);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't need this here as the assert above will fail the test


workspace.openTextDocument(uri).then((err) => {
assert.ok(false, `error in OpenTextDocument ${err}`);
return Promise.reject(err);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as above

Update the client json script
Add Apach 2 copyright to the test files
Add one invalid test file
Add tslint to check all *.ts format.
update minor changes.
remove the failued test case.

Signed-off-by: xufengli <xufengli@uk.ibm.com>
@fenglianxu fenglianxu merged commit 89f7095 into hyperledger-archives:master Jan 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants