Skip to content
Open
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
23 changes: 14 additions & 9 deletions media/livestream/test/livestream.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ before(async () => {
parent: livestreamServiceClient.locationPath(projectId, location),
});
for (const channel of channels) {
if (channel.createTime.seconds < DATE_NOW_SEC - THREE_HOURS_IN_SEC) {
const isTestChannel = channel.name.includes(
'nodejs-test-livestream-channel'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Out of curiosity, why are these channels being filtered, and is this defined anywhere else?

Maybe it is worth to store it in a const or a comment to provide context 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@amcolin Great point! The old code was fetching all channels. I added this filter to make sure we only modify the channels created by this specific test, just to be safe and avoid messing with other people's channels

);
if (isTestChannel) {
const request = {
name: channel.name,
};
Expand All @@ -68,16 +71,18 @@ before(async () => {
console.log(err);
}

const [events] = await livestreamServiceClient.listEvents({
parent: channel.name,
});

for (const event of events) {
await livestreamServiceClient.deleteEvent({
name: event.name,
if (channel.createTime.seconds < DATE_NOW_SEC - THREE_HOURS_IN_SEC) {
const [events] = await livestreamServiceClient.listEvents({
parent: channel.name,
});

for (const event of events) {
await livestreamServiceClient.deleteEvent({
name: event.name,
});
}
await livestreamServiceClient.deleteChannel(request);
}
await livestreamServiceClient.deleteChannel(request);
}
}

Expand Down
Loading