Skip to content

Commit

Permalink
Prefer strict camel case class names
Browse files Browse the repository at this point in the history
  • Loading branch information
Barry Gordon committed Sep 20, 2021
1 parent 906c592 commit 750e512
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 19 deletions.
6 changes: 3 additions & 3 deletions __tests__/api_client.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {APIClient} from '../src/api-client'
import {ApiClient} from '../src/api-client'

describe('APIClient', () => {
describe('ApiClient', () => {
const mockAxios: any = {
get: jest.fn()
}
const api = new APIClient(mockAxios, {
const api = new ApiClient(mockAxios, {
jobId: 1,
jobToken: 'xxx',
credentialsToken: 'yyy',
Expand Down
10 changes: 5 additions & 5 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as core from '@actions/core'
import {Context} from '@actions/github/lib/context'
import {APIClient} from '../src/api-client'
import {ApiClient} from '../src/api-client'
import {Updater} from '../src/updater'
import {ImageService} from '../src/image-service'
import * as inputs from '../src/inputs'
Expand All @@ -21,10 +21,10 @@ describe('run', () => {

beforeEach(async () => {
markJobAsProcessedSpy = jest.spyOn(
APIClient.prototype,
ApiClient.prototype,
'markJobAsProcessed'
)
reportJobErrorSpy = jest.spyOn(APIClient.prototype, 'reportJobError')
reportJobErrorSpy = jest.spyOn(ApiClient.prototype, 'reportJobError')

jest.spyOn(core, 'info').mockImplementation(jest.fn())
jest.spyOn(core, 'setFailed').mockImplementation(jest.fn())
Expand Down Expand Up @@ -114,7 +114,7 @@ describe('run', () => {
describe('when there is an error retrieving job details from DependabotAPI', () => {
beforeEach(() => {
jest
.spyOn(APIClient.prototype, 'getJobDetails')
.spyOn(ApiClient.prototype, 'getJobDetails')
.mockImplementationOnce(
jest.fn(async () =>
Promise.reject(new Error('error getting job details'))
Expand Down Expand Up @@ -148,7 +148,7 @@ describe('run', () => {
describe('when there is an error retrieving job credentials from DependabotAPI', () => {
beforeEach(() => {
jest
.spyOn(APIClient.prototype, 'getCredentials')
.spyOn(ApiClient.prototype, 'getCredentials')
.mockImplementationOnce(
jest.fn(async () =>
Promise.reject(new Error('error getting credentials'))
Expand Down
4 changes: 2 additions & 2 deletions __tests__/updater-integration.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios from 'axios'

import {APIClient, JobParameters} from '../src/api-client'
import {ApiClient, JobParameters} from '../src/api-client'
import {ImageService} from '../src/image-service'
import {UPDATER_IMAGE_NAME, PROXY_IMAGE_NAME} from '../src/main'
import {Updater} from '../src/updater'
Expand All @@ -27,7 +27,7 @@ describe('Updater', () => {
)

const client = axios.create({baseURL: dependabotApiUrl})
const apiClient = new APIClient(client, params)
const apiClient = new ApiClient(client, params)

beforeAll(async () => {
// Skip the test when we haven't preloaded the updater image
Expand Down
6 changes: 3 additions & 3 deletions __tests__/updater.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {UPDATER_IMAGE_NAME, PROXY_IMAGE_NAME} from '../src/main'
import {Updater} from '../src/updater'

describe('Updater', () => {
const mockAPIClient: any = {
const mockApiClient: any = {
getJobDetails: jest.fn(),
getCredentials: jest.fn(),
params: {
Expand All @@ -26,13 +26,13 @@ describe('Updater', () => {
const updater = new Updater(
UPDATER_IMAGE_NAME,
PROXY_IMAGE_NAME,
mockAPIClient,
mockApiClient,
mockJobDetails,
[]
)

it('should fetch job details', async () => {
mockAPIClient.getJobDetails.mockImplementation(() => {
mockApiClient.getJobDetails.mockImplementation(() => {
throw new Error('kaboom')
})
updater.runUpdater()
Expand Down
2 changes: 1 addition & 1 deletion src/api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export type Credential = {
token?: string
}

export class APIClient {
export class ApiClient {
constructor(
private readonly client: AxiosInstance,
readonly params: JobParameters
Expand Down
6 changes: 3 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {Context} from '@actions/github/lib/context'
import {getJobParameters} from './inputs'
import {ImageService} from './image-service'
import {Updater} from './updater'
import {APIClient} from './api-client'
import {ApiClient} from './api-client'
import axios from 'axios'

export const UPDATER_IMAGE_NAME =
Expand Down Expand Up @@ -34,7 +34,7 @@ export async function run(context: Context): Promise<void> {
core.setSecret(params.credentialsToken)

const client = axios.create({baseURL: params.dependabotApiUrl})
const apiClient = new APIClient(client, params)
const apiClient = new ApiClient(client, params)

try {
core.info('Fetching job details')
Expand Down Expand Up @@ -86,7 +86,7 @@ export async function run(context: Context): Promise<void> {
}

async function failJob(
apiClient: APIClient,
apiClient: ApiClient,
error: Error,
errorType = DependabotErrorType.Unknown
): Promise<void> {
Expand Down
4 changes: 2 additions & 2 deletions src/updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as core from '@actions/core'
import Docker, {Container} from 'dockerode'
import path from 'path'
import fs from 'fs'
import {JobDetails, APIClient, Credential} from './api-client'
import {JobDetails, ApiClient, Credential} from './api-client'
import {ContainerService} from './container-service'
import {base64DecodeDependencyFile} from './utils'
import {DependencyFile, FetchedFiles, FileUpdaterInput} from './config-types'
Expand All @@ -22,7 +22,7 @@ export class Updater {
constructor(
private readonly updaterImage: string,
private readonly proxyImage: string,
private readonly apiClient: APIClient,
private readonly apiClient: ApiClient,
private readonly details: JobDetails,
private readonly credentials: Credential[]
) {
Expand Down

0 comments on commit 750e512

Please sign in to comment.