Skip to content

Commit

Permalink
Merge pull request #189 from github-community-projects/sutterj/test-d…
Browse files Browse the repository at this point in the history
…eprecated

fix: replace deprecated createCaller
  • Loading branch information
sutterj authored Jun 18, 2024
2 parents 222aa42 + 08ebe61 commit 3b2d123
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
6 changes: 4 additions & 2 deletions test/server/auth.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { healthCheckerRouter } from '../../src/app/api/trpc/trpc-router'
import { Octomock } from '../octomock'
import { createTestContext } from '../utils/auth'
import { t } from '../../src/utils/trpc-server'
const om = new Octomock()

jest.mock('../../src/bot/octokit', () => ({
Expand All @@ -14,7 +15,8 @@ describe('Git router', () => {
})

it('should allow users that are authenticated', async () => {
const caller = healthCheckerRouter.createCaller(createTestContext())
const caller =
t.createCallerFactory(healthCheckerRouter)(createTestContext())

om.mockFunctions.rest.users.getAuthenticated.mockResolvedValue({
status: 200,
Expand All @@ -33,7 +35,7 @@ describe('Git router', () => {
})

it('should throw on invalid sessions', async () => {
const caller = healthCheckerRouter.createCaller(
const caller = t.createCallerFactory(healthCheckerRouter)(
createTestContext({
user: {
name: 'fake-username',
Expand Down
11 changes: 6 additions & 5 deletions test/server/repos.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import * as auth from '../../src/utils/auth'
import reposRouter from '../../src/server/repos/router'
import { Octomock } from '../octomock'
import { createTestContext } from '../utils/auth'
import { t } from '../../src/utils/trpc-server'
const om = new Octomock()

jest.mock('../../src/bot/config')
Expand Down Expand Up @@ -106,7 +107,7 @@ describe('Repos router', () => {
})

it('should create a mirror when repo does not exist exist', async () => {
const caller = reposRouter.createCaller(createTestContext())
const caller = t.createCallerFactory(reposRouter)(createTestContext())

const configSpy = jest.spyOn(config, 'getConfig').mockResolvedValue({
publicOrg: 'github',
Expand Down Expand Up @@ -151,7 +152,7 @@ describe('Repos router', () => {
})

it('should throw an error when repo already exists', async () => {
const caller = reposRouter.createCaller(createTestContext())
const caller = t.createCallerFactory(reposRouter)(createTestContext())

const configSpy = jest.spyOn(config, 'getConfig').mockResolvedValue({
publicOrg: 'github',
Expand Down Expand Up @@ -185,7 +186,7 @@ describe('Repos router', () => {
})

it('should cleanup repos when there is an error', async () => {
const caller = reposRouter.createCaller(createTestContext())
const caller = t.createCallerFactory(reposRouter)(createTestContext())

const configSpy = jest.spyOn(config, 'getConfig').mockResolvedValue({
publicOrg: 'github',
Expand Down Expand Up @@ -225,7 +226,7 @@ describe('Repos router', () => {
})

it('dual-org: should cleanup repos when there is an error', async () => {
const caller = reposRouter.createCaller(createTestContext())
const caller = t.createCallerFactory(reposRouter)(createTestContext())

const configSpy = jest.spyOn(config, 'getConfig').mockResolvedValue({
publicOrg: 'github',
Expand Down Expand Up @@ -265,7 +266,7 @@ describe('Repos router', () => {
})

it('reject repository names over the character limit', async () => {
const caller = reposRouter.createCaller(createTestContext())
const caller = t.createCallerFactory(reposRouter)(createTestContext())

await caller
.createMirror({
Expand Down

0 comments on commit 3b2d123

Please sign in to comment.