Merge branch 'master' of github.com:thomasabishop/eolas
This commit is contained in:
commit
0268240901
2 changed files with 98 additions and 1 deletions
|
@ -39,7 +39,7 @@ The domain provides network **endpoints** you use to communicate and send reques
|
|||
|
||||
#### Clusters and nodes
|
||||
|
||||
A cluster is the highest level of organisation in OpensSearch that contains your indexed data. It processes all the search queries and handles tasks like indexing, searching, and managing documents.
|
||||
A cluster is the highest level of organisation within an OpensSearch domain that contains your indexed data. It processes all the search queries and handles tasks like indexing, searching, and managing documents.
|
||||
|
||||

|
||||
|
||||
|
@ -188,3 +188,18 @@ Find pages published after a certain date:
|
|||
}
|
||||
}
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"query": {
|
||||
"bool": {
|
||||
"should": [
|
||||
{ "match": { "fileId": "val" } },
|
||||
{ "match": { "programmeId": "val" } },
|
||||
{ "match": { "guid": "val" } }
|
||||
],
|
||||
"minimum_should_match": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
|
|
@ -388,3 +388,85 @@ describe("fetchData", () => {
|
|||
});
|
||||
});
|
||||
```
|
||||
|
||||
## Parameterization
|
||||
|
||||
The following offers a good opportunity for parameterisation:
|
||||
|
||||
```js
|
||||
it("should return page for deletion from `ipages-live`", async () => {
|
||||
// preview = false, isInternal = false
|
||||
await deletePageFromS3("url", false, false);
|
||||
const deleteObjectCommand = s3ClientMock.calls()[0].args[0];
|
||||
expect(deleteObjectCommand.input).toEqual({
|
||||
Bucket: "bbc-ise-ipages-live",
|
||||
Key: "url/index.html",
|
||||
});
|
||||
});
|
||||
|
||||
it("should return page for deletion from `preview`", async () => {
|
||||
// preview = true, isInternal = false
|
||||
await deletePageFromS3("url", true, false);
|
||||
const deleteObjectCommand = s3ClientMock.calls()[0].args[0];
|
||||
expect(deleteObjectCommand.input).toEqual({
|
||||
Bucket: "staff.bbc.com-preview",
|
||||
Key: "preview/url/index.html",
|
||||
});
|
||||
});
|
||||
|
||||
...
|
||||
```
|
||||
|
||||
Each time we are passing in three parameters to the `deletePageFromS3` function which is the object under test. Each time there are different variations in the object that is output.
|
||||
|
||||
To parameterize the process rather than use repeated `it` blocks we can combine the input paramters and outputs into an array:
|
||||
|
||||
```js
|
||||
const testParams = [
|
||||
{
|
||||
preview: false,
|
||||
isInternal: false,
|
||||
bucket: "ipages-live",
|
||||
key: "url/index.html",
|
||||
},
|
||||
{
|
||||
preview: true,
|
||||
isInternal: false,
|
||||
bucket: "staff.com-preview",
|
||||
key: "preview/url/index.html",
|
||||
},
|
||||
];
|
||||
```
|
||||
|
||||
Then use `it.each` to loop through all possible parameter combinations:
|
||||
|
||||
```js
|
||||
it.each(testParams)(
|
||||
"should return page for deletion from %s",
|
||||
async ({ preview, isInternal, bucket, key }) => {
|
||||
await deletePageFromS3("url", preview, isInternal);
|
||||
const deleteObjectCommand = s3ClientMock.calls()[0].args[0];
|
||||
expect(deleteObjectCommand.input).toEqual({
|
||||
Bucket: bucket,
|
||||
Key: key,
|
||||
});
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
This uses the `%s` variable to print the parameters from each test, which outputs:
|
||||
|
||||
```
|
||||
✓ should return page for deletion from {
|
||||
preview: false,
|
||||
isInternal: false,
|
||||
bucket: 'ipages-live',
|
||||
key: 'url/index.html'
|
||||
} (1 ms)
|
||||
✓ should return page for deletion from {
|
||||
preview: true,
|
||||
isInternal: false,
|
||||
bucket: 'staff.com-preview',
|
||||
key: 'preview/url/index.html'
|
||||
}
|
||||
```
|
||||
|
|
Loading…
Add table
Reference in a new issue