Skip to content

Commit

Permalink
test(jest/store): update helmChart and helmRepository tests
Browse files Browse the repository at this point in the history
SXT-1015

Signed-off-by: Alex Marshall <[email protected]>
  • Loading branch information
alexhq committed Jul 26, 2023
1 parent 14dffb6 commit 52849fa
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 2 deletions.
73 changes: 71 additions & 2 deletions jest/store/helmchart.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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'],
},
})

Expand All @@ -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 })
Expand All @@ -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: {
Expand All @@ -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)
})
Expand All @@ -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({
Expand Down
13 changes: 13 additions & 0 deletions jest/store/helmrepository.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
})
})

0 comments on commit 52849fa

Please sign in to comment.