Add createProject example for passing a platform to sentry
Signed-off-by: Brent Swisher <brent@brentswisher.com>
This commit is contained in:
+53
-3
@@ -43,6 +43,7 @@ describe('sentry:project:create action', () => {
|
||||
teamSlug: string;
|
||||
name: string;
|
||||
slug?: string;
|
||||
platform?: string;
|
||||
authToken?: string;
|
||||
}> =>
|
||||
createMockActionContext({
|
||||
@@ -56,12 +57,14 @@ describe('sentry:project:create action', () => {
|
||||
},
|
||||
});
|
||||
|
||||
it(`should ${examples[0].description}`, async () => {
|
||||
it(`should ${examples[0].description} ${
|
||||
yaml.parse(examples[0].example).steps[2].name
|
||||
}`, async () => {
|
||||
expect.assertions(3);
|
||||
|
||||
let input;
|
||||
try {
|
||||
input = yaml.parse(examples[0].example).steps[1].input;
|
||||
input = yaml.parse(examples[0].example).steps[2].input;
|
||||
} catch (error) {
|
||||
console.error('Failed to parse YAML:', error);
|
||||
}
|
||||
@@ -97,7 +100,9 @@ describe('sentry:project:create action', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it(`should ${examples[0].description}`, async () => {
|
||||
it(`should ${examples[0].description} ${
|
||||
yaml.parse(examples[0].example).steps[0].name
|
||||
}`, async () => {
|
||||
expect.assertions(3);
|
||||
|
||||
let input;
|
||||
@@ -140,6 +145,51 @@ describe('sentry:project:create action', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it(`should ${examples[0].description} ${
|
||||
yaml.parse(examples[0].example).steps[1].name
|
||||
}`, async () => {
|
||||
expect.assertions(3);
|
||||
|
||||
let input;
|
||||
try {
|
||||
input = yaml.parse(examples[0].example).steps[1].input;
|
||||
} catch (error) {
|
||||
console.error('Failed to parse YAML:', error);
|
||||
}
|
||||
|
||||
const action = createSentryCreateProjectAction(createScaffolderConfig());
|
||||
const actionContext = getActionContext();
|
||||
actionContext.input = { ...actionContext.input, platform: 'platform-a' };
|
||||
|
||||
worker.use(
|
||||
http.post(
|
||||
`https://sentry.io/api/0/teams/${input.organizationSlug}/${input.teamSlug}/projects/`,
|
||||
async ({ request }) => {
|
||||
expect(request.headers.get('Authorization')).toBe(
|
||||
`Bearer c25711beb516e1e910d2ede554dc1bf725654ef3c75e5a9106de9aec13d5de85`,
|
||||
);
|
||||
expect(request.headers.get('Content-Type')).toBe(`application/json`);
|
||||
await expect(request.json()).resolves.toEqual({
|
||||
name: 'Scaffolded project A',
|
||||
platform: 'platform-a',
|
||||
});
|
||||
return HttpResponse.json(
|
||||
{ detail: 'project creation mocked result' },
|
||||
{ status: 201 },
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
await action.handler({
|
||||
...actionContext,
|
||||
input: {
|
||||
...actionContext.input,
|
||||
...input,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it(`should ${examples[1].description}`, async () => {
|
||||
expect.assertions(3);
|
||||
|
||||
|
||||
@@ -38,7 +38,20 @@ export const examples: TemplateExample[] = [
|
||||
{
|
||||
id: 'create-sentry-project',
|
||||
action: 'sentry:project:create',
|
||||
name: 'Create a Sentry project without providing a project slug.',
|
||||
name: 'Create a Sentry project with provided platform.',
|
||||
input: {
|
||||
organizationSlug: 'my-org',
|
||||
teamSlug: 'team-a',
|
||||
name: 'Scaffolded project A',
|
||||
platform: 'platform-a',
|
||||
authToken:
|
||||
'c25711beb516e1e910d2ede554dc1bf725654ef3c75e5a9106de9aec13d5de85',
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'create-sentry-project',
|
||||
action: 'sentry:project:create',
|
||||
name: 'Create a Sentry project without optional parameters.',
|
||||
input: {
|
||||
organizationSlug: 'my-org',
|
||||
teamSlug: 'team-b',
|
||||
|
||||
Reference in New Issue
Block a user