forked from philippschulte/fastly-promises
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(fastly): Add CRUD support for edge dictionaries
Adds the ability to list (`readDictionaries`), get (`readDictionary`), create (`createDictionary`), update (`updateDictionary`), safely create (`writeDictionary`), and delete (`deleteDictionary`) edge dictionaries. #6
- Loading branch information
Showing
9 changed files
with
538 additions
and
0 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
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
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
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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
'use strict'; | ||
|
||
/* eslint-env mocha */ | ||
|
||
const nock = require('nock'); | ||
const expect = require('expect'); | ||
const config = require('../src/config'); | ||
const fastlyPromises = require('../src/index'); | ||
const response = require('./response/dictionary.response'); | ||
|
||
describe('#createDictionary', () => { | ||
const fastly = fastlyPromises('923b6bd5266a7f932e41962755bd4254', 'SU1Z0isxPaozGVKXdv0eY'); | ||
let res; | ||
|
||
nock(config.mainEntryPoint) | ||
.post('/service/SU1Z0isxPaozGVKXdv0eY/version/1/dictionary') | ||
.reply(200, response.post); | ||
|
||
before(async () => { | ||
res = await fastly.createDictionary(1, { | ||
name: 'my_dictionary', | ||
}); | ||
}); | ||
|
||
it('response should be a status 200', () => { | ||
expect(res.status).toBe(200); | ||
}); | ||
|
||
it('response body should exist', () => { | ||
expect(res.data).toBeTruthy(); | ||
}); | ||
|
||
it('response body should be an object', () => { | ||
expect(typeof res.data).toBe('object'); | ||
}); | ||
|
||
it('response body properties should be created', () => { | ||
expect(res.data.name).toBe('my_dictionary'); | ||
expect(res.data.deleted_at).toBe(null); | ||
expect(res.data.write_only).toBe(false); | ||
}); | ||
|
||
it('response body should contain all properties', () => { | ||
[ | ||
'created_at', | ||
'deleted_at', | ||
'id', | ||
'name', | ||
'service_id', | ||
'updated_at', | ||
'version', | ||
'write_only', | ||
].forEach((e) => { | ||
expect(Object.keys(res.data)).toContain(e); | ||
}); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
'use strict'; | ||
|
||
/* eslint-env mocha */ | ||
|
||
const nock = require('nock'); | ||
const expect = require('expect'); | ||
const config = require('../src/config'); | ||
const fastlyPromises = require('../src/index'); | ||
const response = require('./response/dictionary.response'); | ||
|
||
describe('#deleteDictionary', () => { | ||
const fastly = fastlyPromises('923b6bd5266a7f932e41962755bd4254', 'SU1Z0isxPaozGVKXdv0eY'); | ||
let res; | ||
|
||
nock(config.mainEntryPoint) | ||
.delete('/service/SU1Z0isxPaozGVKXdv0eY/version/1/dictionary/my_dictionary') | ||
.reply(200, response.delete); | ||
|
||
before(async () => { | ||
res = await fastly.deleteDictionary(1, 'my_dictionary'); | ||
}); | ||
|
||
it('response should be a status 200', () => { | ||
expect(res.status).toBe(200); | ||
}); | ||
|
||
it('response body should exist', () => { | ||
expect(res.data).toBeTruthy(); | ||
}); | ||
|
||
it('response body should be an object', () => { | ||
expect(typeof res.data).toBe('object'); | ||
}); | ||
|
||
it('response body properties should be created', () => { | ||
expect(res.data.status).toBe('ok'); | ||
}); | ||
|
||
it('response body should contain all properties', () => { | ||
[ | ||
'status', | ||
].forEach((e) => { | ||
expect(Object.keys(res.data)).toContain(e); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.