Skip to content

Commit

Permalink
fix(shared-utils): Fix addressing in getConfigValue (#16358)
Browse files Browse the repository at this point in the history
* fix(shared-utils): Fix addressing in getConfigValue

* Fix tests

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
norda-gunni and kodiakhq[bot] authored Oct 10, 2024
1 parent 0c4b341 commit ca1cc4e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,32 @@ import { ConfigService } from '@nestjs/config'
import * as utils from './shared.utils'

const mockConfig = {
clientLocationOrigin: 'http://localhost:4242',
baseApiUrl: 'http://localhost:4444',
attachmentBucket: 'attachmentBucket',
templateApi: {
clientLocationOrigin: 'http://localhost:4242/umsoknir',
email: {
sender: 'Devland.is',
address: 'development@island.is',
},
jwtSecret: 'supersecret',
xRoadBasePathWithEnv: '',
SharedModuleConfig: {
clientLocationOrigin: 'http://localhost:4242',
baseApiUrl: 'http://localhost:4444',
presignBucket: '',
attachmentBucket: 'island-is-dev-storage-application-system',
generalPetition: {
endorsementApiBasePath: 'http://localhost:4246',
},
userProfile: {
serviceBasePath: 'http://localhost:3366',
},
islykill: {
cert: '',
passphrase: '',
basePath: '',
attachmentBucket: 'attachmentBucket',
templateApi: {
clientLocationOrigin: 'http://localhost:4242/umsoknir',
email: {
sender: 'Devland.is',
address: 'development@island.is',
},
jwtSecret: 'supersecret',
xRoadBasePathWithEnv: '',
baseApiUrl: 'http://localhost:4444',
presignBucket: '',
attachmentBucket: 'island-is-dev-storage-application-system',
generalPetition: {
endorsementApiBasePath: 'http://localhost:4246',
},
userProfile: {
serviceBasePath: 'http://localhost:3366',
},
islykill: {
cert: '',
passphrase: '',
basePath: '',
},
},
},
}
Expand Down Expand Up @@ -92,7 +94,7 @@ describe('shared utils', () => {
let configService: ConfigService<SharedModuleConfig>

beforeEach(() => {
configService = new ConfigService<SharedModuleConfig>(mockConfig)
configService = new ConfigService(mockConfig)
})

it('should get the client location origin from the config', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ export const createAssignToken = (
}

export const getConfigValue = (
configService: ConfigService<SharedModuleConfig>,
configService: ConfigService,
key: keyof SharedModuleConfig,
) => {
const value = configService.get(key)
const value = configService.get(`SharedModuleConfig.${key}`)

if (value === undefined) {
throw new Error(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import { ApplicationTypes } from '@island.is/application/types'
import { sharedModuleConfig } from '../../shared'

const mockConfig = {
templateApi: {
attachmentBucket: 'island-is-dev-storage-application-system',
SharedModuleConfig: {
templateApi: {
attachmentBucket: 'island-is-dev-storage-application-system',
},
},
}

Expand Down

0 comments on commit ca1cc4e

Please sign in to comment.