Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

docs(samples): update samples to use async/await and mocha #183

Merged
merged 15 commits into from
Nov 3, 2018

Conversation

muraliQlogic
Copy link
Contributor

@muraliQlogic muraliQlogic commented Oct 22, 2018

Works towards googleapis/google-cloud-node#2865 and googleapis/google-cloud-node#2869 (it's a good idea to open an issue first for discussion)

  • Tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

<!doctype html>
<h1>Hello World</h1>
<p>This page was created from a simple start-up script!</p>`,
(async() =>{

This comment was marked as spam.

@@ -26,110 +26,114 @@ const zone = compute.zone('us-central1-a');
function createVm(name, callback) {

This comment was marked as spam.

ip
);

}catch(err){

This comment was marked as spam.

zone
.getVMs()
.then(data => {
(async () => {

This comment was marked as spam.

.then(data => {
(async () => {
try{
const data = await zone.getVMs();

This comment was marked as spam.

};
},

describe('sendgrid',() =>{

This comment was marked as spam.

samples/test/sendgrid.test.js Show resolved Hide resolved
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Oct 22, 2018
@JustinBeckwith JustinBeckwith changed the title Samples to use async/await and mocha docs(samples): update samples to use async/await and mocha Oct 25, 2018
.catch(err => {
console.error('ERROR:', err);
});
const name = 'ubuntu-http1';

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

const vm = data[0];
const operation = data[1];
// Virtual machine created!
return operation.promise();

This comment was marked as spam.

} else {
console.log('Mail sent successfully!');
}
const response = Sendgrid.API(request);

This comment was marked as spam.

};
const vm = zone.vm(name);
console.log('Creating VM ...');
const data = await vm.create(config);

This comment was marked as spam.

This comment was marked as spam.

console.log('Creating VM ...');
const data = await vm.create(config);
await data[1].promise();
const metadata = await vm.getMetadata();

This comment was marked as spam.


const vm = zone.vm(name);
// External IP of the VM.
const ip = metadata[0].networkInterfaces[0].accessConfigs[0].natIP;

This comment was marked as spam.

const ip = metadata.networkInterfaces[0].accessConfigs[0].natIP;
console.log(`Booting new VM with IP http://${ip}...`);
// Ping the VM to determine when the HTTP server is ready.
return await pingVM(ip);

This comment was marked as spam.

This comment was marked as spam.

samples/startup-script/index.js Show resolved Hide resolved
.catch(err => callback(err));
async function listVms() {
try {
const data = await zone.getVMs();

This comment was marked as spam.

await pingVM(ip);
return ip;
} catch (err) {
console.error(`Something went wrong while creating ${name} :`, err);

This comment was marked as spam.

This comment was marked as spam.

try {
const [vms] = await zone.getVMs();
const results = [];
for (const i in vms) {

This comment was marked as spam.

This comment was marked as spam.

name: data[0].name,
};
});
} catch (err) {

This comment was marked as spam.

This comment was marked as spam.

samples/startup-script/index.js Outdated Show resolved Hide resolved
// VM deleted
return name;
} catch (err) {
console.error(`Something went wrong while deleting ${name} :`, err);

This comment was marked as spam.

This comment was marked as spam.

"axios": "^0.18.0"
},
"engines": {
"node": ">=7.6.0"

This comment was marked as spam.

This comment was marked as spam.

samples/vms_api.js Show resolved Hide resolved
@JustinBeckwith JustinBeckwith added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 29, 2018
@kokoro-team kokoro-team removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 29, 2018
@JustinBeckwith
Copy link
Contributor

@muraliQlogic as soon as the samples tests are passing, would be happy to merge this one :) Let me know if you need any help!

@muraliQlogic
Copy link
Contributor Author

@JustinBeckwith : Can you please invoke the samples test check.

@@ -4,15 +4,19 @@
"description": "Start a Google Compute Engine and run the startup script.",
"main": "index.js",
"dependencies": {
"@google-cloud/compute": "0.10.0"
"@google-cloud/compute": "0.10.0",
"axios": "^0.18.0"

This comment was marked as spam.

This comment was marked as spam.

@JustinBeckwith
Copy link
Contributor

@muraliQlogic I sent an invite to the googleapis org on GitHub. If you accept that, it will run the tests for you instead of needing one of us to add a kokoro label :)

@JustinBeckwith JustinBeckwith added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 30, 2018
@kokoro-team kokoro-team removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 30, 2018
@muraliQlogic
Copy link
Contributor Author

@JustinBeckwith : samples test are passing locally with other project that i am testing with.

@codecov
Copy link

codecov bot commented Oct 30, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@cbffc90). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #183   +/-   ##
=========================================
  Coverage          ?   99.25%           
=========================================
  Files             ?       19           
  Lines             ?     1476           
  Branches          ?        0           
=========================================
  Hits              ?     1465           
  Misses            ?       11           
  Partials          ?        0

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cbffc90...d5a376e. Read the comment docs.

@sduskis sduskis added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 2, 2018
@kokoro-team kokoro-team removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 2, 2018
@sduskis
Copy link

sduskis commented Nov 2, 2018

@JustinBeckwith, @muraliQlogic can't add labels for some reason..

@sduskis sduskis added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 2, 2018
@kokoro-team kokoro-team removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 2, 2018
@JustinBeckwith
Copy link
Contributor

I just ran sloth users, can you try again?

@sduskis
Copy link

sduskis commented Nov 2, 2018

The samples tests show this:

npm ERR! Failed at the @google-cloud/[email protected] samples-test script.

@JustinBeckwith JustinBeckwith merged commit 4038d26 into googleapis:master Nov 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants