diff --git a/test/resources/1111111/user/retrieve-expected.md b/test/resources/1111111/user/retrieve-expected.md
new file mode 100644
index 000000000..50eb1b2ec
--- /dev/null
+++ b/test/resources/1111111/user/retrieve-expected.md
@@ -0,0 +1,19 @@
+# User Overview - testInstance
+
+## Users (1)
+
+| Name | Last successful Login | Active | Access Locked out | API User | Must change PW | Default BU | BU Access | Roles | Login | ID | Key | E-Mail | Notification E-Mail | Timezone | SFMC Locale | Modified Date | Modified By | Created Date |
+| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
+| user test | 96 days | ✓ | - | - | - | _ParentBU_ (1111111) | _ParentBU_ (1111111),
testBU (9999999) | Administrator,
Content Creator,
Marketing Cloud Administrator | user_test@accenture.asgr | 700301950 | testExisting_user | user_test@accenture.com | user_test@accenture.com | GMT+01:00 | en-GB | 2022-06-21 01:43:02.64 | 123456 | 2019-09-06 01:59:07.097 |
+
+
+## Inactivated Users (0)
+
+| Name | Last successful Login | Active | Access Locked out | API User | Must change PW | Default BU | BU Access | Roles | Login | ID | Key | E-Mail | Notification E-Mail | Timezone | SFMC Locale | Modified Date | Modified By | Created Date |
+| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
+
+
+## Installed Packages (0)
+
+| Name | Last successful Login | Active | Access Locked out | API User | Must change PW | Default BU | BU Access | Roles | Login | ID | Key | E-Mail | Notification E-Mail | Timezone | SFMC Locale | Modified Date | Modified By | Created Date |
+| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
diff --git a/test/resources/9999999/dataExtension/retrieve-expected.md b/test/resources/9999999/dataExtension/retrieve-expected.md
new file mode 100644
index 000000000..fda321a2d
--- /dev/null
+++ b/test/resources/9999999/dataExtension/retrieve-expected.md
@@ -0,0 +1,18 @@
+## testExisting_dataExtension
+
+**Description:** bla bla
+
+**Folder:** Data Extensions/
+
+**Fields in table:** 4
+
+**Sendable:** Yes (`ContactKey` to `Subscriber Key`)
+
+**Testable:** Yes
+
+| Name | FieldType | MaxLength | IsPrimaryKey | IsNullable | DefaultValue |
+| --- | --- | --- | --- | --- | --- |
+| FirstName | Text | 50 | - | + | |
+| LastName | Text | 50 | - | + | |
+| EmailAddress | EmailAddress | 254 | - | - | |
+| ContactKey | Text | 50 | + | - | |
diff --git a/test/type.dataExtension.test.js b/test/type.dataExtension.test.js
index b91a2f496..968a0d164 100644
--- a/test/type.dataExtension.test.js
+++ b/test/type.dataExtension.test.js
@@ -1,4 +1,8 @@
-const assert = require('chai').assert;
+const chai = require('chai');
+const chaiFiles = require('chai-files');
+const assert = chai.assert;
+const expect = chai.expect;
+const file = chaiFiles.file;
const cache = require('../lib/util/cache');
const testUtils = require('./utils');
const handler = require('../lib/index');
@@ -29,6 +33,13 @@ describe('type: dataExtension', () => {
'returned metadata was not equal expected'
);
+ // check if MD file was created and equals expectations
+ expect(
+ file(testUtils.getActualDoc('testExisting_dataExtension', 'dataExtension'))
+ ).to.equal(
+ file(testUtils.getExpectedFile('9999999', 'dataExtension', 'retrieve', 'md'))
+ );
+
assert.equal(
testUtils.getAPIHistoryLength(),
5,
diff --git a/test/type.user.test.js b/test/type.user.test.js
index 26be1696c..697c5a5f7 100644
--- a/test/type.user.test.js
+++ b/test/type.user.test.js
@@ -1,4 +1,9 @@
-const assert = require('chai').assert;
+const chai = require('chai');
+const chaiFiles = require('chai-files');
+const assert = chai.assert;
+chai.use(chaiFiles);
+const expect = chai.expect;
+const file = chaiFiles.file;
const cache = require('../lib/util/cache');
const testUtils = require('./utils');
const handler = require('../lib/index');
@@ -29,6 +34,11 @@ describe('type: user', () => {
'returned metadata was not equal expected'
);
+ // check if MD file was created and equals expectations
+ expect(file(`./docs/user/testInstance.users.md`)).to.equal(
+ file(testUtils.getExpectedFile('1111111', 'user', 'retrieve', 'md'))
+ );
+
assert.equal(
testUtils.getAPIHistoryLength(),
6,
@@ -36,6 +46,22 @@ describe('type: user', () => {
);
return;
});
+ it('Should retrieve a specific user but not run document', async () => {
+ // WHEN
+ await handler.retrieve('testInstance/_ParentBU_', ['user'], ['testExisting_user']);
+ // THEN
+ assert.equal(process.exitCode, false, 'retrieve should not have thrown an error');
+
+ // because user is single-document-type we would not want to find an md file when we retrieve specific keys. only the generic retrieve updates it
+ expect(file(`./docs/user/testInstance.users.md`)).to.not.exist;
+
+ assert.equal(
+ testUtils.getAPIHistoryLength(),
+ 4,
+ 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
+ );
+ return;
+ });
});
describe('Deploy ================', () => {
beforeEach(() => {
@@ -74,6 +100,9 @@ describe('type: user', () => {
await testUtils.getExpectedJson('1111111', 'user', 'update'),
'returned metadata was not equal expected for update'
);
+ // because user is single-document-type we would not want to find an md file getting created by deploy. only retrieve updates it
+ expect(file(`./docs/user/testInstance.users.md`)).to.not.exist;
+
assert.equal(
testUtils.getAPIHistoryLength(),
9,
diff --git a/test/utils.js b/test/utils.js
index 5f1e64809..6f0a628e1 100644
--- a/test/utils.js
+++ b/test/utils.js
@@ -22,6 +22,16 @@ const resourceFactory = require('./resourceFactory');
*/
exports.getActualJson = (customerKey, type, buName = 'testBU') =>
File.readJSON(`./retrieve/testInstance/${buName}/${type}/${customerKey}.${type}-meta.json`);
+/**
+ * gets file from Retrieve folder
+ *
+ * @param {string} customerKey of metadata
+ * @param {string} type of metadata
+ * @param {string} [buName] used when we need to test on ParentBU
+ * @returns {Promise.} file in string form
+ */
+exports.getActualDoc = (customerKey, type, buName = 'testBU') =>
+ `./retrieve/testInstance/${buName}/${type}/${customerKey}.${type}-doc.md`;
/**
* gets file from Retrieve folder
*