Skip to content

Commit

Permalink
fix: deployment test, sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
mvayngrib committed Jul 16, 2018
1 parent d1a3f10 commit d4827a0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
14 changes: 11 additions & 3 deletions src/in-house-bot/deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1183,6 +1183,10 @@ ${this.genUsageInstructions(links)}`
if (tag === 'latest') return this.getLatestVersionInfo()

return await this.bot.db.findOne({
orderBy: {
property: '_time',
desc: true
},
filter: {
EQ: {
[TYPE]: VERSION_INFO,
Expand All @@ -1194,7 +1198,7 @@ ${this.genUsageInstructions(links)}`
}

public getLatestVersionInfo = async ():Promise<VersionInfo> => {
return await this.bot.db.findOne({
const { items } = await this.bot.db.find({
orderBy: {
property: 'sortableTag',
desc: true
Expand All @@ -1206,6 +1210,8 @@ ${this.genUsageInstructions(links)}`
}
}
})

return _.maxBy(items, '_time')
}

public saveVersionInfo = async (versionInfo: VersionInfo) => {
Expand Down Expand Up @@ -1350,7 +1356,7 @@ ${this.genUsageInstructions(links)}`
}
})

return items
return sortVersions(items)
}

public listDownloadedUpdates = async (providerPermalink?: string) => {
Expand All @@ -1374,7 +1380,7 @@ ${this.genUsageInstructions(links)}`
}
})

return items
return sortVersions(items)
}

private saveMyDeploymentVersionInfo = async () => {
Expand Down Expand Up @@ -1557,3 +1563,5 @@ const shouldSendVersionAlert = (versionInfo: VersionInfo) => {

return ALERT_BRANCHES.includes(versionInfo.branch)
}

const sortVersions = (items: any[]) => _.sortBy(items, ['sortableTag', '_time'])
6 changes: 5 additions & 1 deletion src/test/in-house-bot/deployment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,14 +397,18 @@ test('deployment by referral', loudAsync(async (t) => {
return {
templateUrl: 'original.template.url',
tag,
sortableTag: utils.toSortableTag(tag)
}
})

sandbox.stub(parentDeployment, '_getTemplateByUrl').resolves(parentTemplate)

let updateResponse
const { templateUrl } = await parentDeployment.handleUpdateRequest({
from: childIdentity,
from: {
id: buildResource.permalink(childIdentity),
identity: childIdentity
},
req: updateReq
})

Expand Down

0 comments on commit d4827a0

Please sign in to comment.