Skip to content

Commit

Permalink
Finished.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmdobry committed Nov 4, 2016
1 parent 4bbd8b3 commit 6478988
Show file tree
Hide file tree
Showing 7 changed files with 284 additions and 296 deletions.
17 changes: 17 additions & 0 deletions functions/gcs/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,23 @@ describe(`functions:gcs`, () => {
);
});

it(`Does nothing for deleted files`, (done) => {
const event = {
data: {
resourceState: `not_exists`
}
};
const sample = getSample();

sample.program.wordCount(event, (err, message) => {
assert.ifError(err);
assert.equal(message, undefined);
assert.deepEqual(sample.mocks.storage.bucket.callCount, 0);
assert.deepEqual(sample.mocks.bucket.file.callCount, 0);
done();
});
});

it(`Reads the file line by line`, (done) => {
const expectedMsg = `File ${filename} has 114 words`;
const event = {
Expand Down
30 changes: 15 additions & 15 deletions functions/ocr/app/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
// Copyright 2016, Google, Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* Copyright 2016, Google, Inc.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

Expand Down Expand Up @@ -37,9 +39,7 @@ const translate = require('@google-cloud/translate')({
*/
function publishResult (topicName, data) {
return pubsub.topic(topicName).get({ autoCreate: true })
.then(([topic]) => {
return topic.publish({ data })
});
.then(([topic]) => topic.publish({ data }));
}
// [END functions_ocr_publish]

Expand Down
26 changes: 14 additions & 12 deletions functions/ocr/app/test/index.test.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
// Copyright 2016, Google, Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* Copyright 2016, Google, Inc.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

Expand Down
Loading

0 comments on commit 6478988

Please sign in to comment.