-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'next' into kanad-2024-12-04/remove-deprecated-commands
- Loading branch information
Showing
6 changed files
with
126 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ import { describe, beforeAll, afterAll, beforeEach, it, expect } from 'vitest'; | |
|
||
import Command from '../../../src/commands/changelogs.js'; | ||
import { APIv1Error } from '../../../src/lib/apiError.js'; | ||
import { getAPIV1Mock } from '../../helpers/get-api-mock.js'; | ||
import { getAPIv1Mock } from '../../helpers/get-api-mock.js'; | ||
import hashFileContents from '../../helpers/hash-file-contents.js'; | ||
import { runCommandAndReturnResult } from '../../helpers/oclif.js'; | ||
|
||
|
@@ -67,15 +67,15 @@ describe('rdme changelogs', () => { | |
it('should fetch changelog and merge with what is returned', () => { | ||
expect.assertions(1); | ||
|
||
const getMocks = getAPIV1Mock() | ||
const getMocks = getAPIv1Mock() | ||
.get('/api/v1/changelogs/simple-doc') | ||
.basicAuth({ user: key }) | ||
.reply(200, { slug: simpleDoc.slug, lastUpdatedHash: 'anOldHash' }) | ||
.get('/api/v1/changelogs/another-doc') | ||
.basicAuth({ user: key }) | ||
.reply(200, { slug: anotherDoc.slug, lastUpdatedHash: 'anOldHash' }); | ||
|
||
const updateMocks = getAPIV1Mock() | ||
const updateMocks = getAPIv1Mock() | ||
.put('/api/v1/changelogs/simple-doc', { | ||
body: simpleDoc.doc.content, | ||
lastUpdatedHash: simpleDoc.hash, | ||
|
@@ -112,7 +112,7 @@ describe('rdme changelogs', () => { | |
it('should return changelog update info for dry run', () => { | ||
expect.assertions(1); | ||
|
||
const getMocks = getAPIV1Mock() | ||
const getMocks = getAPIv1Mock() | ||
.get('/api/v1/changelogs/simple-doc') | ||
.basicAuth({ user: key }) | ||
.reply(200, { slug: simpleDoc.slug, lastUpdatedHash: 'anOldHash' }) | ||
|
@@ -141,7 +141,7 @@ describe('rdme changelogs', () => { | |
it('should not send requests for changelogs that have not changed', () => { | ||
expect.assertions(1); | ||
|
||
const getMocks = getAPIV1Mock() | ||
const getMocks = getAPIv1Mock() | ||
.get('/api/v1/changelogs/simple-doc') | ||
.basicAuth({ user: key }) | ||
.reply(200, { slug: simpleDoc.slug, lastUpdatedHash: simpleDoc.hash }) | ||
|
@@ -164,7 +164,7 @@ describe('rdme changelogs', () => { | |
it('should adjust "no changes" message if in dry run', () => { | ||
expect.assertions(1); | ||
|
||
const getMocks = getAPIV1Mock() | ||
const getMocks = getAPIv1Mock() | ||
.get('/api/v1/changelogs/simple-doc') | ||
.basicAuth({ user: key }) | ||
.reply(200, { slug: simpleDoc.slug, lastUpdatedHash: simpleDoc.hash }) | ||
|
@@ -192,7 +192,7 @@ describe('rdme changelogs', () => { | |
const doc = frontMatter(fs.readFileSync(path.join(fullFixturesDir, `/new-docs/${slug}.md`))); | ||
const hash = hashFileContents(fs.readFileSync(path.join(fullFixturesDir, `/new-docs/${slug}.md`))); | ||
|
||
const getMock = getAPIV1Mock() | ||
const getMock = getAPIv1Mock() | ||
.get(`/api/v1/changelogs/${slug}`) | ||
.basicAuth({ user: key }) | ||
.reply(404, { | ||
|
@@ -202,7 +202,7 @@ describe('rdme changelogs', () => { | |
help: 'If you need help, email [email protected] and mention log "fake-metrics-uuid".', | ||
}); | ||
|
||
const postMock = getAPIV1Mock() | ||
const postMock = getAPIv1Mock() | ||
.post('/api/v1/changelogs', { slug, body: doc.content, ...doc.data, lastUpdatedHash: hash }) | ||
.basicAuth({ user: key }) | ||
.reply(201, { slug, _id: id, body: doc.content, ...doc.data, lastUpdatedHash: hash }); | ||
|
@@ -219,7 +219,7 @@ describe('rdme changelogs', () => { | |
const slug = 'new-doc'; | ||
const doc = frontMatter(fs.readFileSync(path.join(fullFixturesDir, `/new-docs/${slug}.md`))); | ||
|
||
const getMock = getAPIV1Mock() | ||
const getMock = getAPIv1Mock() | ||
.get(`/api/v1/changelogs/${slug}`) | ||
.basicAuth({ user: key }) | ||
.reply(404, { | ||
|
@@ -254,7 +254,7 @@ describe('rdme changelogs', () => { | |
|
||
const hash = hashFileContents(fs.readFileSync(path.join(fullFixturesDir, `/${folder}/${slug}.md`))); | ||
|
||
const getMocks = getAPIV1Mock() | ||
const getMocks = getAPIv1Mock() | ||
.get(`/api/v1/changelogs/${slug}`) | ||
.basicAuth({ user: key }) | ||
.reply(404, { | ||
|
@@ -264,7 +264,7 @@ describe('rdme changelogs', () => { | |
help: 'If you need help, email [email protected] and mention log "fake-metrics-uuid".', | ||
}); | ||
|
||
const postMocks = getAPIV1Mock() | ||
const postMocks = getAPIv1Mock() | ||
.post('/api/v1/changelogs', { slug, body: doc.content, ...doc.data, lastUpdatedHash: hash }) | ||
.basicAuth({ user: key }) | ||
.reply(400, errorObject); | ||
|
@@ -292,7 +292,7 @@ describe('rdme changelogs', () => { | |
const doc = frontMatter(fs.readFileSync(path.join(fullFixturesDir, `/slug-docs/${slug}.md`))); | ||
const hash = hashFileContents(fs.readFileSync(path.join(fullFixturesDir, `/slug-docs/${slug}.md`))); | ||
|
||
const getMock = getAPIV1Mock() | ||
const getMock = getAPIv1Mock() | ||
.get(`/api/v1/changelogs/${doc.data.slug}`) | ||
.basicAuth({ user: key }) | ||
.reply(404, { | ||
|
@@ -302,7 +302,7 @@ describe('rdme changelogs', () => { | |
help: 'If you need help, email [email protected] and mention log "fake-metrics-uuid".', | ||
}); | ||
|
||
const postMock = getAPIV1Mock() | ||
const postMock = getAPIv1Mock() | ||
.post('/api/v1/changelogs', { slug, body: doc.content, ...doc.data, lastUpdatedHash: hash }) | ||
.basicAuth({ user: key }) | ||
.reply(201, { slug: doc.data.slug, _id: id, body: doc.content, ...doc.data, lastUpdatedHash: hash }); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ import { describe, beforeAll, afterAll, beforeEach, it, expect } from 'vitest'; | |
|
||
import Command from '../../../src/commands/changelogs.js'; | ||
import { APIv1Error } from '../../../src/lib/apiError.js'; | ||
import { getAPIV1Mock } from '../../helpers/get-api-mock.js'; | ||
import { getAPIv1Mock } from '../../helpers/get-api-mock.js'; | ||
import hashFileContents from '../../helpers/hash-file-contents.js'; | ||
import { runCommandAndReturnResult } from '../../helpers/oclif.js'; | ||
|
||
|
@@ -49,7 +49,7 @@ describe('rdme changelogs (single)', () => { | |
const doc = frontMatter(fs.readFileSync(path.join(fullFixturesDir, `/new-docs/${slug}.md`))); | ||
const hash = hashFileContents(fs.readFileSync(path.join(fullFixturesDir, `/new-docs/${slug}.md`))); | ||
|
||
const getMock = getAPIV1Mock() | ||
const getMock = getAPIv1Mock() | ||
.get(`/api/v1/changelogs/${slug}`) | ||
.basicAuth({ user: key }) | ||
.reply(404, { | ||
|
@@ -59,7 +59,7 @@ describe('rdme changelogs (single)', () => { | |
help: 'If you need help, email [email protected] and mention log "fake-metrics-uuid".', | ||
}); | ||
|
||
const postMock = getAPIV1Mock() | ||
const postMock = getAPIv1Mock() | ||
.post('/api/v1/changelogs', { slug, body: doc.content, ...doc.data, lastUpdatedHash: hash }) | ||
.basicAuth({ user: key }) | ||
.reply(201, { slug, _id: id, body: doc.content, ...doc.data }); | ||
|
@@ -76,7 +76,7 @@ describe('rdme changelogs (single)', () => { | |
const slug = 'new-doc'; | ||
const doc = frontMatter(fs.readFileSync(path.join(fullFixturesDir, `/new-docs/${slug}.md`))); | ||
|
||
const getMock = getAPIV1Mock() | ||
const getMock = getAPIv1Mock() | ||
.get(`/api/v1/changelogs/${slug}`) | ||
.basicAuth({ user: key }) | ||
.reply(404, { | ||
|
@@ -113,7 +113,7 @@ describe('rdme changelogs (single)', () => { | |
help: 'If you need help, email [email protected] and mention log "fake-metrics-uuid".', | ||
}; | ||
|
||
const getMock = getAPIV1Mock().get(`/api/v1/changelogs/${slug}`).basicAuth({ user: key }).reply(500, errorObject); | ||
const getMock = getAPIv1Mock().get(`/api/v1/changelogs/${slug}`).basicAuth({ user: key }).reply(500, errorObject); | ||
|
||
const filePath = `./__tests__/${fixturesBaseDir}/failure-docs/${slug}.md`; | ||
|
||
|
@@ -135,7 +135,7 @@ describe('rdme changelogs (single)', () => { | |
const doc = frontMatter(fs.readFileSync(path.join(fullFixturesDir, `/slug-docs/${slug}.md`))); | ||
const hash = hashFileContents(fs.readFileSync(path.join(fullFixturesDir, `/slug-docs/${slug}.md`))); | ||
|
||
const getMock = getAPIV1Mock() | ||
const getMock = getAPIv1Mock() | ||
.get(`/api/v1/changelogs/${doc.data.slug}`) | ||
.basicAuth({ user: key }) | ||
.reply(404, { | ||
|
@@ -145,7 +145,7 @@ describe('rdme changelogs (single)', () => { | |
help: 'If you need help, email [email protected] and mention log "fake-metrics-uuid".', | ||
}); | ||
|
||
const postMock = getAPIV1Mock() | ||
const postMock = getAPIv1Mock() | ||
.post('/api/v1/changelogs', { slug, body: doc.content, ...doc.data, lastUpdatedHash: hash }) | ||
.basicAuth({ user: key }) | ||
.reply(201, { slug: doc.data.slug, _id: id, body: doc.content, ...doc.data, lastUpdatedHash: hash }); | ||
|
@@ -172,12 +172,12 @@ describe('rdme changelogs (single)', () => { | |
}); | ||
|
||
it('should fetch changelog and merge with what is returned', () => { | ||
const getMock = getAPIV1Mock() | ||
const getMock = getAPIv1Mock() | ||
.get('/api/v1/changelogs/simple-doc') | ||
.basicAuth({ user: key }) | ||
.reply(200, { slug: simpleDoc.slug, lastUpdatedHash: 'anOldHash' }); | ||
|
||
const updateMock = getAPIV1Mock() | ||
const updateMock = getAPIv1Mock() | ||
.put('/api/v1/changelogs/simple-doc', { | ||
body: simpleDoc.doc.content, | ||
lastUpdatedHash: simpleDoc.hash, | ||
|
@@ -202,7 +202,7 @@ describe('rdme changelogs (single)', () => { | |
it('should return changelog update info for dry run', () => { | ||
expect.assertions(1); | ||
|
||
const getMock = getAPIV1Mock() | ||
const getMock = getAPIv1Mock() | ||
.get('/api/v1/changelogs/simple-doc') | ||
.basicAuth({ user: key }) | ||
.reply(200, { slug: simpleDoc.slug, lastUpdatedHash: 'anOldHash' }); | ||
|
@@ -227,7 +227,7 @@ describe('rdme changelogs (single)', () => { | |
it('should not send requests for changelogs that have not changed', () => { | ||
expect.assertions(1); | ||
|
||
const getMock = getAPIV1Mock() | ||
const getMock = getAPIv1Mock() | ||
.get('/api/v1/changelogs/simple-doc') | ||
.basicAuth({ user: key }) | ||
.reply(200, { slug: simpleDoc.slug, lastUpdatedHash: simpleDoc.hash }); | ||
|
@@ -240,7 +240,7 @@ describe('rdme changelogs (single)', () => { | |
}); | ||
|
||
it('should adjust "no changes" message if in dry run', () => { | ||
const getMock = getAPIV1Mock() | ||
const getMock = getAPIv1Mock() | ||
.get('/api/v1/changelogs/simple-doc') | ||
.basicAuth({ user: key }) | ||
.reply(200, { slug: simpleDoc.slug, lastUpdatedHash: simpleDoc.hash }); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ import { describe, beforeAll, afterAll, afterEach, it, expect } from 'vitest'; | |
import Command from '../../src/commands/login.js'; | ||
import { APIv1Error } from '../../src/lib/apiError.js'; | ||
import configStore from '../../src/lib/configstore.js'; | ||
import { getAPIV1Mock } from '../helpers/get-api-mock.js'; | ||
import { getAPIv1Mock } from '../helpers/get-api-mock.js'; | ||
import { runCommandAndReturnResult } from '../helpers/oclif.js'; | ||
|
||
const apiKey = 'abcdefg'; | ||
|
@@ -39,7 +39,7 @@ describe('rdme login', () => { | |
it('should post to /login on the API', async () => { | ||
prompts.inject([email, password, project]); | ||
|
||
const mock = getAPIV1Mock().post('/api/v1/login', { email, password, project }).reply(200, { apiKey }); | ||
const mock = getAPIv1Mock().post('/api/v1/login', { email, password, project }).reply(200, { apiKey }); | ||
|
||
await expect(run()).resolves.toBe('Successfully logged in as [email protected] to the subdomain project.'); | ||
|
||
|
@@ -53,7 +53,7 @@ describe('rdme login', () => { | |
it('should post to /login on the API if passing in project via opt', async () => { | ||
prompts.inject([email, password]); | ||
|
||
const mock = getAPIV1Mock().post('/api/v1/login', { email, password, project }).reply(200, { apiKey }); | ||
const mock = getAPIv1Mock().post('/api/v1/login', { email, password, project }).reply(200, { apiKey }); | ||
|
||
await expect(run(['--project', project])).resolves.toBe( | ||
'Successfully logged in as [email protected] to the subdomain project.', | ||
|
@@ -67,7 +67,7 @@ describe('rdme login', () => { | |
}); | ||
|
||
it('should bypass prompts and post to /login on the API if passing in every opt', async () => { | ||
const mock = getAPIV1Mock().post('/api/v1/login', { email, password, project, token }).reply(200, { apiKey }); | ||
const mock = getAPIv1Mock().post('/api/v1/login', { email, password, project, token }).reply(200, { apiKey }); | ||
|
||
await expect(run(['--email', email, '--password', password, '--project', project, '--otp', token])).resolves.toBe( | ||
'Successfully logged in as [email protected] to the subdomain project.', | ||
|
@@ -81,7 +81,7 @@ describe('rdme login', () => { | |
}); | ||
|
||
it('should bypass prompts and post to /login on the API if passing in every opt (no 2FA)', async () => { | ||
const mock = getAPIV1Mock().post('/api/v1/login', { email, password, project }).reply(200, { apiKey }); | ||
const mock = getAPIv1Mock().post('/api/v1/login', { email, password, project }).reply(200, { apiKey }); | ||
|
||
await expect(run(['--email', email, '--password', password, '--project', project])).resolves.toBe( | ||
'Successfully logged in as [email protected] to the subdomain project.', | ||
|
@@ -103,7 +103,7 @@ describe('rdme login', () => { | |
help: 'If you need help, email [email protected] and mention log "fake-metrics-uuid".', | ||
}; | ||
|
||
const mock = getAPIV1Mock().post('/api/v1/login', { email, password, project }).reply(401, errorResponse); | ||
const mock = getAPIv1Mock().post('/api/v1/login', { email, password, project }).reply(401, errorResponse); | ||
|
||
await expect(run()).rejects.toStrictEqual(new APIv1Error(errorResponse)); | ||
mock.done(); | ||
|
@@ -118,7 +118,7 @@ describe('rdme login', () => { | |
help: 'If you need help, email [email protected] and mention log "fake-metrics-uuid".', | ||
}; | ||
|
||
const mock = getAPIV1Mock() | ||
const mock = getAPIv1Mock() | ||
.post('/api/v1/login', { email, password, project }) | ||
.reply(401, errorResponse) | ||
.post('/api/v1/login', { email, password, project, token }) | ||
|
@@ -143,7 +143,7 @@ describe('rdme login', () => { | |
help: 'If you need help, email [email protected]', | ||
}; | ||
|
||
const mock = getAPIV1Mock() | ||
const mock = getAPIv1Mock() | ||
.post('/api/v1/login', { email, password, project: projectThatIsNotYours }) | ||
.reply(404, errorResponse); | ||
|
||
|
Oops, something went wrong.