Skip to content

Commit

Permalink
#846: add RETRIEVE test for type dataExtract
Browse files Browse the repository at this point in the history
  • Loading branch information
JoernBerkefeld committed Jul 18, 2023
1 parent b6ecf31 commit d599a58
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
[
{
"name": "Audit Trail Activity Log",
"extractId": "d804ddf9-feda-4495-8e7e-069a14f5d248"
},
{
"name": "Zip",
"extractId": "9a487c7d-96bd-484c-ad80-0f0bcbb91ca7"
},
{
"name": "Tracking Extract",
"extractId": "c7219016-a7f0-4c72-8657-1ec12c28a0db"
},
{
"name": "Mobile Push Detail Extract Report",
"extractId": "e6647310-ac95-4f32-a639-2a6b145c83f1"
},
{
"name": "UTF16 to ASCII Converter",
"extractId": "e7e14f95-b925-462d-b6b4-4a6b1dca7ca1"
},
{
"name": "Contacts Without Channel Addresses",
"extractId": "f2500d28-b3cb-42b9-ad31-361123ec1222"
},
{
"name": "Convert XML",
"extractId": "805dfb29-82cb-43dc-989b-53ef5d181920"
},
{
"name": "GZip",
"extractId": "7e7d322a-88ca-499a-9fb3-90e72fcf00af"
},
{
"name": "XmlToTextMapper",
"extractId": "cf2cd221-fc3c-4d9f-90b4-a4e879a51ab6"
},
{
"name": "Enhanced FTP File Move and Copy",
"extractId": "90d90e0a-fd9a-4d35-b471-cde0d17c91d4"
},
{
"name": "Data Extension Extract",
"extractId": "bb94a04d-9632-4623-be47-daabc3f588a6"
},
{
"name": "Audit Trail Access Log",
"extractId": "382b94bd-bd1b-45e1-864f-eb824841885a"
}
]
39 changes: 39 additions & 0 deletions test/resources/9999999/dataExtract/get-expected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"createdBy": 700301950,
"createdDate": "2022-11-09T05:31:21.667",
"dataFields": [
{
"name": "ColumnDelimiter",
"type": "string",
"value": ","
},
{
"name": "DECustomerKey",
"type": "string",
"value": "testExisting_dataExtension"
},
{
"name": "HasColumnHeaders",
"type": "bool",
"value": "False"
},
{
"name": "TextQualified",
"type": "bool",
"value": "False"
},
{
"name": "UsesLineFeed",
"type": "bool",
"value": "False"
}
],
"description": "blabla",
"fileSpec": "testExisting-%%Year%%-%%Month%%-%%Day%%",
"intervalType": 0,
"key": "testExisting_dataExtract",
"modifiedBy": 700301950,
"modifiedDate": "2022-11-17T07:13:36.9",
"name": "testExisting_dataExtract",
"r__dataExtractType_name": "Data Extension Extract"
}
43 changes: 43 additions & 0 deletions test/type.dataExtract.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const chai = require('chai');
const chaiFiles = require('chai-files');
const assert = chai.assert;
chai.use(chaiFiles);
const cache = require('../lib/util/cache');
const testUtils = require('./utils');
const handler = require('../lib/index');

describe('type: dataExtract', () => {
beforeEach(() => {
testUtils.mockSetup();
});
afterEach(() => {
testUtils.mockReset();
});

describe('Retrieve ================', () => {
it('Should retrieve a dataExtract', async () => {
// WHEN
await handler.retrieve('testInstance/testBU', ['dataExtract']);
// THEN
assert.equal(process.exitCode, false, 'retrieve should not have thrown an error');
// get results from cache
const result = cache.getCache();
assert.equal(
result.dataExtract ? Object.keys(result.dataExtract).length : 0,
1,
'only one dataExtract expected'
);
assert.deepEqual(
await testUtils.getActualJson('testExisting_dataExtract', 'dataExtract'),
await testUtils.getExpectedJson('9999999', 'dataExtract', 'get'),
'returned JSON was not equal expected'
);
assert.equal(
testUtils.getAPIHistoryLength(),
6,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
return;
});
});
});

0 comments on commit d599a58

Please sign in to comment.