Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions functions/ocr/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ const translate = new Translate();

// [END functions_ocr_setup]

// [START functions_ocr_publish]
/**
* Publishes the result to the given pubsub topic and returns a Promise.
*
Expand All @@ -45,7 +44,6 @@ const publishResult = async (topicName, data) => {
const [topic] = await pubsub.topic(topicName).get({autoCreate: true});
topic.publish(dataBuffer);
};
// [END functions_ocr_publish]

// [START functions_ocr_detect]
/**
Expand Down Expand Up @@ -83,14 +81,16 @@ const detectText = async (bucketName, filename) => {
lang: lang,
};

// Helper function that publishes translation result to a Pub/Sub topic
// For more information on publishing Pub/Sub messages, see this page:
// https://cloud.google.com/pubsub/docs/publisher
return publishResult(topicName, messageData);
});

return Promise.all(tasks);
};
// [END functions_ocr_detect]

// [START functions_ocr_rename]
/**
* Appends a .txt suffix to the image name.
*
Expand All @@ -101,7 +101,6 @@ const detectText = async (bucketName, filename) => {
const renameImageForSave = (filename, lang) => {
return `${filename}_to_${lang}.txt`;
};
// [END functions_ocr_rename]

// [START functions_ocr_process]
/**
Expand Down
6 changes: 3 additions & 3 deletions functions/ocr/app/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('processImage', () => {
});
});

describe('functions_ocr_process functions_ocr_detect functions_ocr_publish', () => {
describe('functions_ocr_process functions_ocr_detect', () => {
it('processImage detects text', async () => {
const data = {
bucket: bucketName,
Expand Down Expand Up @@ -96,7 +96,7 @@ describe('translateText', () => {
});
});

describe('functions_ocr_translate functions_ocr_publish', () => {
describe('functions_ocr_translate', () => {
it('translateText translates and publishes text', async () => {
const data = {
data: Buffer.from(
Expand Down Expand Up @@ -131,7 +131,7 @@ describe('saveResult', () => {
});
});

describe('functions_ocr_save functions_ocr_rename', () => {
describe('functions_ocr_save', () => {
it('saveResult translates and publishes text', async () => {
const data = {
data: Buffer.from(JSON.stringify({text, filename, lang})).toString(
Expand Down