-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update redis service and github service (#256)
* Update redis service and github service * Fix: github testing * feat: alterations (#257) * feat: refactor event source location * fix: refresh after generating --------- Co-authored-by: Matthew Bystedt <[email protected]> Co-authored-by: Matthew Bystedt <[email protected]>
- Loading branch information
1 parent
68de6b7
commit 66dadd9
Showing
23 changed files
with
612 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { HealthIndicator, HealthIndicatorResult } from '@nestjs/terminus'; | ||
import { GithubService } from './github.service'; | ||
|
||
@Injectable() | ||
export class GithubHealthIndicator extends HealthIndicator { | ||
constructor(private readonly githubService: GithubService) { | ||
super(); | ||
} | ||
async isHealthy(key: string): Promise<HealthIndicatorResult> { | ||
const result = this.getStatus(key, this.githubService.isEnabled(), { | ||
enabled: this.githubService.isEnabled(), | ||
}); | ||
|
||
return result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { GithubService } from './github.service'; | ||
import { VaultModule } from '../vault/vault.module'; | ||
import { RedisModule } from '../redis/redis.module'; | ||
import { GithubHealthIndicator } from './github.health'; | ||
|
||
@Module({ | ||
imports: [VaultModule, RedisModule], | ||
providers: [GithubService, GithubHealthIndicator], | ||
exports: [GithubService, GithubHealthIndicator], | ||
}) | ||
export class GithubModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { createMock } from '@golevelup/ts-jest'; | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { GithubService } from './github.service'; | ||
|
||
describe('GithubService', () => { | ||
let service: GithubService; | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
providers: [GithubService], | ||
}) | ||
.useMocker(createMock) | ||
.compile(); | ||
|
||
service = module.get<GithubService>(GithubService); | ||
}); | ||
|
||
it('should be defined', () => { | ||
expect(service).toBeDefined(); | ||
}); | ||
|
||
describe('getOwnerAndRepoFromUrl', () => { | ||
it('should extract owner and repo from URL', () => { | ||
const repoUrl = 'https://github.com/myorg/mytestrepo.git'; | ||
const result = service['getOwnerAndRepoFromUrl'](repoUrl); // Using private method directly for testing | ||
|
||
expect(result).toEqual({ owner: 'myorg', repo: 'mytestrepo' }); | ||
}); | ||
|
||
it('should throw an error for invalid URL', () => { | ||
const repoUrl = 'invalid_url'; | ||
expect(() => service['getOwnerAndRepoFromUrl'](repoUrl)).toThrow( | ||
'Invalid GitHub URL', | ||
); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.