diff --git a/contract-tests/sdkClientEntity.js b/contract-tests/sdkClientEntity.js index 376a6f810..3830730d4 100644 --- a/contract-tests/sdkClientEntity.js +++ b/contract-tests/sdkClientEntity.js @@ -80,6 +80,13 @@ function getExecution(order) { } } +function makeMigrationPostOptions(payload) { + if (payload) { + return { body: payload }; + } + return {}; +} + export async function newSdkClientEntity(options) { const c = {}; const log = Log(options.tag); @@ -170,33 +177,45 @@ export async function newSdkClientEntity(options) { latencyTracking: migrationOperation.trackLatency, errorTracking: migrationOperation.trackErrors, check: migrationOperation.trackConsistency ? (a, b) => a === b : undefined, - readNew: async () => { + readNew: async (payload) => { try { - const res = await got.post(migrationOperation.newEndpoint, {}); + const res = await got.post( + migrationOperation.newEndpoint, + makeMigrationPostOptions(payload), + ); return LDMigrationSuccess(res.body); } catch (err) { return LDMigrationError(err.message); } }, - writeNew: async () => { + writeNew: async (payload) => { try { - const res = await got.post(migrationOperation.newEndpoint, {}); + const res = await got.post( + migrationOperation.newEndpoint, + makeMigrationPostOptions(payload), + ); return LDMigrationSuccess(res.body); } catch (err) { return LDMigrationError(err.message); } }, - readOld: async () => { + readOld: async (payload) => { try { - const res = await got.post(migrationOperation.oldEndpoint, {}); + const res = await got.post( + migrationOperation.oldEndpoint, + makeMigrationPostOptions(payload), + ); return LDMigrationSuccess(res.body); } catch (err) { return LDMigrationError(err.message); } }, - writeOld: async () => { + writeOld: async (payload) => { try { - const res = await got.post(migrationOperation.oldEndpoint, {}); + const res = await got.post( + migrationOperation.oldEndpoint, + makeMigrationPostOptions(payload), + ); return LDMigrationSuccess(res.body); } catch (err) { return LDMigrationError(err.message); @@ -210,6 +229,7 @@ export async function newSdkClientEntity(options) { migrationOperation.key, migrationOperation.context, migrationOperation.defaultStage, + migrationOperation.payload, ); if (res.success) { return { result: res.result }; @@ -222,6 +242,7 @@ export async function newSdkClientEntity(options) { migrationOperation.key, migrationOperation.context, migrationOperation.defaultStage, + migrationOperation.payload, ); if (res.authoritative.success) {