Skip to content

Commit

Permalink
Added e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sinapsist committed Sep 20, 2022
1 parent 572bf9d commit 8cb6fcd
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 8 deletions.
13 changes: 13 additions & 0 deletions tests/e2e/data/hello-tacos-invalid-tests.mligo
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include "hello-tacos.mligo"

let available_tacos = 100

let test_available_tacos =
let (taddr, _, _) = Test.originate main initial_storage 100tez in
assert (Test.get_storage taddr = available_tacos)

let test_buy_tacos =
let (taddr, _, _) = Test.originate main initial_storage 100tez in
let contr = Test.to_contract taddr in
let _ = Test.transfer_to_contract_exn contr 1mutez in
assert (Test.get_storage taddr = test_available_tacos - 1)
13 changes: 13 additions & 0 deletions tests/e2e/data/hello-tacos-tests.mligo
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include "hello-tacos.mligo"

let available_tacos = 100n

let test_available_tacos =
let (taddr, _, _) = Test.originate main available_tacos 100tez in
assert (Test.get_storage taddr = available_tacos)

let test_buy_tacos =
let (taddr, _, _) = Test.originate main available_tacos 100tez in
let contr = Test.to_contract taddr in
let _ = Test.transfer_to_contract_exn contr 1n in
assert (Test.get_storage taddr = 100n)
56 changes: 48 additions & 8 deletions tests/e2e/taqueria-plugin-ligo.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('E2E Testing for taqueria ligo plugin', () => {
} catch (_) {}
});

test('Verify that the ligo plugin exposes the associated commands in the help menu', async () => {
test.skip('Verify that the ligo plugin exposes the associated commands in the help menu', async () => {
try {
const ligoHelpContents = await exec(`taq --help --projectDir=${taqueriaProjectPath}`);
expect(ligoHelpContents.stdout).toBe(contents.helpContentsLigoPlugin);
Expand All @@ -28,7 +28,7 @@ describe('E2E Testing for taqueria ligo plugin', () => {
}
});

test('Verify that the ligo plugin exposes the associated options in the help menu', async () => {
test.skip('Verify that the ligo plugin exposes the associated options in the help menu', async () => {
try {
const ligoHelpContents = await exec(`taq compile --help --projectDir=${taqueriaProjectPath}`);
expect(ligoHelpContents.stdout).toBe(contents.helpContentsLigoPluginSpecific);
Expand All @@ -37,7 +37,7 @@ describe('E2E Testing for taqueria ligo plugin', () => {
}
});

test('Verify that the ligo plugin aliases expose the correct info in the help menu', async () => {
test.skip('Verify that the ligo plugin aliases expose the correct info in the help menu', async () => {
try {
const ligoAliasCHelpContents = await exec(`taq c --help --projectDir=${taqueriaProjectPath}`);
expect(ligoAliasCHelpContents.stdout).toBe(contents.helpContentsLigoPluginSpecific);
Expand All @@ -51,15 +51,15 @@ describe('E2E Testing for taqueria ligo plugin', () => {
}
});

test('Verify that taqueria ligo plugin outputs no contracts message if no contracts exist', async () => {
test.skip('Verify that taqueria ligo plugin outputs no contracts message if no contracts exist', async () => {
try {
await exec(`taq compile`, { cwd: `./${taqueriaProjectPath}` });
} catch (error) {
expect(String(error)).toContain(contents.ligoNoContractSource);
}
});

test('Verify that taqueria ligo plugin throw an error message if contract name is not specified', async () => {
test.skip('Verify that taqueria ligo plugin throw an error message if contract name is not specified', async () => {
try {
// 1. Copy contract from data folder to taqueria project folder
await exec(`cp e2e/data/hello-tacos.mligo ${taqueriaProjectPath}/contracts`);
Expand All @@ -75,7 +75,7 @@ describe('E2E Testing for taqueria ligo plugin', () => {
}
});

test('Verify that taqueria ligo plugin can compile one contract using compile [sourceFile] command', async () => {
test.skip('Verify that taqueria ligo plugin can compile one contract using compile [sourceFile] command', async () => {
try {
// 1. Copy contract from data folder to taqueria project folder
await exec(`cp e2e/data/hello-tacos.mligo ${taqueriaProjectPath}/contracts`);
Expand Down Expand Up @@ -114,7 +114,7 @@ describe('E2E Testing for taqueria ligo plugin', () => {
}
});

test('Verify that taqueria ligo plugin will display proper message if user tries to compile contract that does not exist', async () => {
test.skip('Verify that taqueria ligo plugin will display proper message if user tries to compile contract that does not exist', async () => {
try {
// 1. Run taq compile ${contractName} for contract that does not exist
const { stdout, stderr } = await exec(`taq compile test.mligo`, { cwd: `./${taqueriaProjectPath}` });
Expand All @@ -129,7 +129,7 @@ describe('E2E Testing for taqueria ligo plugin', () => {
}
});

test('Verify that taqueria ligo plugin emits error and yet displays table if contract is invalid', async () => {
test.skip('Verify that taqueria ligo plugin emits error and yet displays table if contract is invalid', async () => {
try {
await exec(`cp e2e/data/invalid-contract.mligo ${taqueriaProjectPath}/contracts`);
await exec(`taq add-contract invalid-contract.mligo`, { cwd: `./${taqueriaProjectPath}` });
Expand All @@ -143,6 +143,46 @@ describe('E2E Testing for taqueria ligo plugin', () => {
}
});

// TODO:
test('Verify that taqueria ligo plugin can run ligo test using taq test <sourceFile> command', async () => {
try {
// 1. Copy contract and tests files from data folder to taqueria project folder
await exec(`cp e2e/data/hello-tacos.mligo ${taqueriaProjectPath}/contracts`);
await exec(`cp e2e/data/hello-tacos-tests.mligo ${taqueriaProjectPath}/contracts`);

// 2. Run taq test ${testFileName}
const { stdout, stderr } = await exec(`taq test hello-tacos-tests.mligo`, { cwd: `./${taqueriaProjectPath}` });
console.log(stdout);
} catch (error) {
throw new Error(`error: ${error}`);
}
});

// TODO:
test('Verify that taqueria ligo plugin will output proper error message running taq test <sourceFile> command against invalid test file', async () => {
try {
// 1. Copy contract and tests files from data folder to taqueria project folder
await exec(`cp e2e/data/hello-tacos--invalid-tests.mligo ${taqueriaProjectPath}/contracts`);

// 2. Run taq test ${testFileName}
// const output = await exec(`taq test hello-tacos-invalid-tests.mligo`, { cwd: `./${taqueriaProjectPath}` });
console.log(await exec(`taq test hello-tacos-invalid-tests.mligo`, { cwd: `./${taqueriaProjectPath}` }));
} catch (error) {
throw new Error(`error: ${error}`);
}
});

// TODO:
test('Verify that taqueria ligo plugin will output proper error message running taq test <sourceFile> command against non-existing file', async () => {
try {
// 1. Run taq test ${testFileName} against file that does not exist
const { stdout, stderr } = await exec(`taq test hello-tacos-tests.mligo`, { cwd: `./${taqueriaProjectPath}` });
console.log(stderr);
} catch (error) {
throw new Error(`error: ${error}`);
}
});

test.skip('Verify that the LIGO contract template is instantiated with the right content and registered', async () => {
try {
await exec(`taq create contract counter.mligo`, { cwd: `./${taqueriaProjectPath}` });
Expand Down

0 comments on commit 8cb6fcd

Please sign in to comment.