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
8 changes: 4 additions & 4 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1731,7 +1731,7 @@ async function findProjectHashOnServer (ow, projectName) {
// check for package with the projectName in manifest File and if found -> return the projectHash on the server
const resultSync = await ow.packages.list(options)
for (const pkg of resultSync) {
if (pkg.annotations.length > 0) {
if (pkg.annotations?.length > 0) {
const whiskManaged = pkg.annotations.find(elem => elem.key === 'whisk-managed')
if (whiskManaged !== undefined && whiskManaged.value.projectName === projectName) {
projectHash = whiskManaged.value.projectHash
Expand All @@ -1742,7 +1742,7 @@ async function findProjectHashOnServer (ow, projectName) {
// if no package exists with the projectName -> look in actions
const resultActionList = await ow.actions.list()
for (const action of resultActionList) {
if (action.annotations.length > 0) {
if (action.annotations?.length > 0) {
const whiskManaged = action.annotations.find(elem => elem.key === 'whisk-managed')
if (whiskManaged !== undefined && whiskManaged.value.projectName === projectName) {
projectHash = whiskManaged.value.projectHash
Expand All @@ -1754,7 +1754,7 @@ async function findProjectHashOnServer (ow, projectName) {
// if no action exists with the projectName -> look in triggers
const resultTriggerList = await ow.triggers.list()
for (const trigger of resultTriggerList) {
if (trigger.annotations.length > 0) {
if (trigger.annotations?.length > 0) {
const whiskManaged = trigger.annotations.find(elem => elem.key === 'whisk-managed')
if (whiskManaged !== undefined && whiskManaged.value.projectName === projectName) {
projectHash = whiskManaged.value.projectHash
Expand All @@ -1766,7 +1766,7 @@ async function findProjectHashOnServer (ow, projectName) {
// if no trigger exists with the projectName -> look in rules
const resultRules = await ow.rules.list()
for (const rule of resultRules) {
if (rule.annotations.length > 0) {
if (rule.annotations?.length > 0) {
const whiskManaged = rule.annotations.find(elem => elem.key === 'whisk-managed')
if (whiskManaged !== undefined &&
whiskManaged.value.projectName === projectName) {
Expand Down
14 changes: 14 additions & 0 deletions test/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1936,6 +1936,20 @@ describe('getProjectHash', () => {
})

describe('findProjectHashOnServer', () => {
test('default projectHash (null annotations in packages, actions, triggers, rules)', async () => {
const testProjectName = 'ThisIsTheNameOfTheProject'
const pkgList = ow.mockResolved('packages.list', [{ annotations: null }])
const actList = ow.mockResolved('actions.list', [{ annotations: null }])
const trgList = ow.mockResolved('triggers.list', [{ annotations: null }])
const rlzList = ow.mockResolved('rules.list', [{ annotations: null }])
const result = await utils.findProjectHashOnServer(ow, testProjectName)
expect(pkgList).toHaveBeenCalled()
expect(actList).toHaveBeenCalled()
expect(trgList).toHaveBeenCalled()
expect(rlzList).toHaveBeenCalled()
expect(result).toBe('')
})

test('default projectHash (no packages, actions, triggers, rules found)', async () => {
const testProjectName = 'ThisIsTheNameOfTheProject'
const pkgList = ow.mockResolved('packages.list', '')
Expand Down