Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add createdAt key to json in registry #532

Merged
merged 7 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions src/targets/__tests__/registry.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
jest.mock('../../utils/githubApi.ts');
import { getGitHubClient } from '../../utils/githubApi';
import { RegistryConfig, RegistryTarget } from '../registry';
import { NoneArtifactProvider } from '../../artifact_providers/none';
import { RegistryPackageType } from '../../utils/registry';

describe('getUpdatedManifest', () => {
let mockClient: jest.Mock;

beforeEach(() => {
jest.resetAllMocks();
mockClient = jest.fn();
(getGitHubClient as jest.MockedFunction<
typeof getGitHubClient
// @ts-ignore we only need to mock a subset
>).mockReturnValue({ graphql: mockClient });
});

const target = new RegistryTarget(
{ name: 'pypi' },
new NoneArtifactProvider(),
{ owner: 'testSourceOwner', repo: 'testSourceRepo' }
);

it('check if createdAt exists', async () => {
const registryConfig: RegistryConfig = {
type: RegistryPackageType.SDK,
canonicalName: 'example-package',
};
const packageManifest = {
canonical: 'example-package',
};
const canonical = 'example-package';
const version = '1.2.3';
const revision = 'abc123';

const updatedManifest = await target.getUpdatedManifest(
registryConfig,
packageManifest,
canonical,
version,
revision
);

// check if property createdAt exists
expect(updatedManifest).toHaveProperty('createdAt');
});
});
10 changes: 9 additions & 1 deletion src/targets/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,15 @@ export class RegistryTarget extends BaseTarget {
);
}
// Update the manifest
const updatedManifest = { ...packageManifest, version };
const updatedManifest: {
version: string;
createdAt: string;
[key: string]: any;
} = {
...packageManifest,
version,
createdAt: new Date().toISOString(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a plan to backfill this data?

any test that needs updating?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a simple unit test to check if property is there
here is the PR to backfill the data for existing files
getsentry/sentry-release-registry#148

};

// Add file links if it's a generic app (legacy)
if (registryConfig.type === RegistryPackageType.APP) {
Expand Down
Loading