From a5d6a492b0f160da4b789d8a6f134b63d2604ee2 Mon Sep 17 00:00:00 2001 From: Alex Marshall Date: Wed, 26 Jul 2023 14:21:40 +0100 Subject: [PATCH] test(jest/store): update helmChart and helmRepository tests SXT-1015 Signed-off-by: Alex Marshall --- jest/store/helmchart.test.ts | 73 ++++++++++++++++++++++++++++++- jest/store/helmrepository.test.ts | 13 ++++++ 2 files changed, 84 insertions(+), 2 deletions(-) diff --git a/jest/store/helmchart.test.ts b/jest/store/helmchart.test.ts index 3a9b41a0..4b074eda 100644 --- a/jest/store/helmchart.test.ts +++ b/jest/store/helmchart.test.ts @@ -41,7 +41,9 @@ describe('HelmChartStore', () => { repository_id: repo.id, icon: 'https://example.com/icon.png', version: '1.0.0', + verified: false, keywords: ['test', 'chart'], + urls: ['https://example.com/chart.tgz'], }, }) expect(chart).toMatchObject({ @@ -60,7 +62,9 @@ describe('HelmChartStore', () => { repository_id: repo.id, icon: 'https://example.com/icon.png', version: '1.0.0', + verified: false, keywords: ['test', 'chart'], + urls: ['https://example.com/chart.tgz'], }, }) @@ -82,7 +86,9 @@ describe('HelmChartStore', () => { repository_id: repo.id, icon: 'https://example.com/icon.png', version: '1.0.0', + verified: false, keywords: ['test', 'chart'], + urls: ['https://example.com/chart.tgz'], }, }) const getChart = await store.get({ id: chart.id }) @@ -91,6 +97,67 @@ describe('HelmChartStore', () => { }) }) + it('should get an exact helm chart', async () => { + const chart = await store.create({ + data: { + active: true, + name: 'test-chart-getexact', + app_version: '1.0.0', + description: 'test chart description', + digest: 'test-digest', + repository_id: repo.id, + icon: 'https://example.com/icon.png', + version: '1.0.0', + verified: false, + keywords: ['test', 'chart'], + urls: ['https://example.com/chart.tgz'], + }, + }) + const getChart = await store.getExact({ + name: chart.name, + version: chart.version, + repository_id: chart.repository_id, + }) + expect(getChart).toMatchObject({ + ...chart, + }) + }) + + it('should get matching helm charts', async () => { + const chartOne = await store.create({ + data: { + active: true, + name: 'test-chart-getmatching', + app_version: '1.0.0', + description: 'test chart description one', + digest: 'test-digest', + repository_id: repo.id, + icon: 'https://example.com/icon.png', + version: '1.0.0', + verified: false, + keywords: ['test', 'chart'], + urls: ['https://example.com/chart-100.tgz'], + }, + }) + const chartTwo = await store.create({ + data: { + active: true, + name: 'test-chart-getmatching', + app_version: '2.0.0', + description: 'test chart description', + digest: 'test-digest', + repository_id: repo.id, + icon: 'https://example.com/icon.png', + version: '2.0.0', + verified: false, + keywords: ['test', 'chart'], + urls: ['https://example.com/chart-200.tgz'], + }, + }) + const matchingCharts = await store.getMatching({ name: chartOne.name }) + expect(matchingCharts.length).toBe(2) + }) + it('should list all helm charts', async () => { const chart = await store.create({ data: { @@ -102,11 +169,11 @@ describe('HelmChartStore', () => { repository_id: repo.id, icon: 'https://example.com/icon.png', version: '1.0.0', + verified: false, keywords: ['test', 'chart'], + urls: ['https://example.com/chart.tgz'], }, }) - await store.delete({ id: chart.id }) - const charts = await store.list() expect(charts.length).toBeGreaterThan(0) }) @@ -122,7 +189,9 @@ describe('HelmChartStore', () => { repository_id: repo.id, icon: 'https://example.com/icon.png', version: '1.0.0', + verified: false, keywords: ['test', 'chart'], + urls: ['https://example.com/chart.tgz'], }, }) const updatedChart = await store.update({ diff --git a/jest/store/helmrepository.test.ts b/jest/store/helmrepository.test.ts index d6ac30f2..6e70f80e 100644 --- a/jest/store/helmrepository.test.ts +++ b/jest/store/helmrepository.test.ts @@ -97,4 +97,17 @@ describe('HelmRepositoryStore', () => { active: 'false', }) }) + it('should get a helm chart by url', async () => { + const repo = await helmRepoStore.create({ + data: { + name: 'test-repo-getbyurl', + active: true, + url: 'https://charts.example.com/url', + }, + }) + const getRepo = await helmRepoStore.getByUrl({ url: repo.url }) + expect(getRepo).toMatchObject({ + ...repo, + }) + }) })