Added entity tests
This commit is contained in:
@@ -37,10 +37,10 @@ export class GithubFork {
|
||||
@Column({ name: 'open_issues', transformer: numberToBigIntTransformer })
|
||||
public openIssues!: number;
|
||||
|
||||
@Column({ name: 'network', type: 'integer', nullable: true })
|
||||
@Column({ name: 'network', transformer: numberToBigIntTransformer, nullable: true })
|
||||
public network?: number;
|
||||
|
||||
@Column({ name: 'subscribers', type: 'integer', nullable: true })
|
||||
@Column({ name: 'subscribers', transformer: numberToBigIntTransformer, nullable: true })
|
||||
public subscribers?: number;
|
||||
|
||||
@Column({ name: 'default_branch' })
|
||||
@@ -49,13 +49,13 @@ export class GithubFork {
|
||||
@Column({ name: 'status', nullable: true })
|
||||
public status?: string;
|
||||
|
||||
@Column({ name: 'ahead_by', type: 'integer', nullable: true })
|
||||
@Column({ name: 'ahead_by', transformer: numberToBigIntTransformer, nullable: true })
|
||||
public aheadBy?: number;
|
||||
|
||||
@Column({ name: 'behind_by', type: 'integer', nullable: true })
|
||||
@Column({ name: 'behind_by', transformer: numberToBigIntTransformer, nullable: true })
|
||||
public behindBy?: number;
|
||||
|
||||
@Column({ name: 'total_commits', type: 'integer', nullable: true })
|
||||
@Column({ name: 'total_commits', transformer: numberToBigIntTransformer, nullable: true })
|
||||
public totalCommits?: number;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { GithubForkResponse, GithubComparisonResponse } from '../../data_sources/github';
|
||||
import { GithubComparisonResponse, GithubForkResponse } from '../../data_sources/github';
|
||||
import { GithubFork } from '../../entities';
|
||||
|
||||
/**
|
||||
|
||||
84
packages/pipeline/test/entities/github_test.ts
Normal file
84
packages/pipeline/test/entities/github_test.ts
Normal file
@@ -0,0 +1,84 @@
|
||||
import 'mocha';
|
||||
import 'reflect-metadata';
|
||||
|
||||
import { GithubFork, GithubPullRequest, GithubRepo } from '../../src/entities';
|
||||
import { createDbConnectionOnceAsync } from '../db_setup';
|
||||
import { chaiSetup } from '../utils/chai_setup';
|
||||
|
||||
import { testSaveAndFindEntityAsync } from './util';
|
||||
|
||||
chaiSetup.configure();
|
||||
|
||||
// tslint:disable:custom-no-magic-numbers
|
||||
const fork: GithubFork = {
|
||||
observedTimestamp: Date.now(),
|
||||
name: '0x-monorepo',
|
||||
ownerLogin: 'NoahZinsmeister',
|
||||
createdAt: 1552181010000,
|
||||
updatedAt: 1552191123000,
|
||||
pushedAt: 1552191120000,
|
||||
size: 86271,
|
||||
stargazers: 0,
|
||||
watchers: 0,
|
||||
forks: 0,
|
||||
openIssues: 0,
|
||||
network: undefined,
|
||||
subscribers: undefined,
|
||||
defaultBranch: 'development',
|
||||
status: 'ahead',
|
||||
aheadBy: 1,
|
||||
behindBy: 0,
|
||||
totalCommits: 1,
|
||||
};
|
||||
|
||||
const pullRequest: GithubPullRequest = {
|
||||
observedTimestamp: Date.now(),
|
||||
repoName: '0x-monorepo',
|
||||
pullRequestNumber: 1684,
|
||||
state: 'open',
|
||||
title: '[WIP] Pull Github data',
|
||||
userLogin: 'askeluv',
|
||||
createdAt: 1552019788000,
|
||||
updatedAt: 1552019788000,
|
||||
closedAt: null,
|
||||
mergedAt: null,
|
||||
};
|
||||
|
||||
const repo: GithubRepo = {
|
||||
observedTimestamp: Date.now(),
|
||||
name: '0x-monorepo',
|
||||
createdAt: 1495549053000,
|
||||
updatedAt: 1551908929000,
|
||||
pushedAt: 1551916745000,
|
||||
size: 86538,
|
||||
stargazers: 989,
|
||||
watchers: 989,
|
||||
forks: 294,
|
||||
openIssues: 46,
|
||||
network: 294,
|
||||
subscribers: 89,
|
||||
};
|
||||
|
||||
describe('GithubFork entity', () => {
|
||||
it('save/find', async () => {
|
||||
const connection = await createDbConnectionOnceAsync();
|
||||
const forksRepository = connection.getRepository(GithubFork);
|
||||
await testSaveAndFindEntityAsync(forksRepository, fork);
|
||||
});
|
||||
});
|
||||
|
||||
describe('GithubPullRequest entity', () => {
|
||||
it('save/find', async () => {
|
||||
const connection = await createDbConnectionOnceAsync();
|
||||
const pullRequestRepository = connection.getRepository(GithubPullRequest);
|
||||
await testSaveAndFindEntityAsync(pullRequestRepository, pullRequest);
|
||||
});
|
||||
});
|
||||
|
||||
describe('GithubRepo entity', () => {
|
||||
it('save/find', async () => {
|
||||
const connection = await createDbConnectionOnceAsync();
|
||||
const repoRepository = connection.getRepository(GithubRepo);
|
||||
await testSaveAndFindEntityAsync(repoRepository, repo);
|
||||
});
|
||||
});
|
||||
@@ -1,12 +1,12 @@
|
||||
import * as chai from 'chai';
|
||||
import 'mocha';
|
||||
|
||||
import { GithubForkResponse, GithubComparisonResponse } from '../../../src/data_sources/github';
|
||||
import { parseGithubForks, enrichGithubForkWithComparisonDetails } from '../../../src/parsers/github';
|
||||
import { GithubComparisonResponse, GithubForkResponse } from '../../../src/data_sources/github';
|
||||
import { enrichGithubForkWithComparisonDetails, parseGithubForks } from '../../../src/parsers/github';
|
||||
|
||||
import { ParsedGithubFork, EnrichedGithubFork } from '../../fixtures/github/api_v3_forks';
|
||||
import * as githubForksResponse from '../../fixtures/github/api_v3_forks.json';
|
||||
import * as githubComparisonResponse from '../../fixtures/github/api_v3_compare.json';
|
||||
import { EnrichedGithubFork, ParsedGithubFork } from '../../fixtures/github/api_v3_forks';
|
||||
import * as githubForksResponse from '../../fixtures/github/api_v3_forks.json';
|
||||
|
||||
import { chaiSetup } from '../../utils/chai_setup';
|
||||
|
||||
@@ -34,5 +34,4 @@ describe('github_forks', () => {
|
||||
expect(actual).deep.equal(expected);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user