This commit is contained in:
Ashita Prasad
2025-02-23 23:58:48 +05:30
parent 9a6130dd53
commit 0ef5a800fd
2 changed files with 17 additions and 4 deletions

View File

@ -86,7 +86,11 @@ HttpRequestModel substituteHttpRequestModel(
value: substituteVariables(param.value, envMap, activeEnvironmentId), value: substituteVariables(param.value, envMap, activeEnvironmentId),
); );
}).toList(), }).toList(),
body: substituteVariables(httpRequestModel.body, envMap, activeEnvironmentId), body: substituteVariables(
httpRequestModel.body,
envMap,
activeEnvironmentId,
),
); );
return newRequestModel; return newRequestModel;
} }

View File

@ -211,10 +211,12 @@ void main() {
NameValueModel(name: "num", value: "{{num}}"), NameValueModel(name: "num", value: "{{num}}"),
], ],
); );
Map<String?, List<EnvironmentVariableModel>> envMap = { Map<String?, List<EnvironmentVariableModel>> envMap = {
kGlobalEnvironmentId: globalVars, kGlobalEnvironmentId: globalVars,
"activeEnvId": activeEnvVars, "activeEnvId": activeEnvVars,
}; };
String? activeEnvironmentId = "activeEnvId"; String? activeEnvironmentId = "activeEnvId";
const expected = HttpRequestModel( const expected = HttpRequestModel(
url: "api.apidash.dev/humanize/social", url: "api.apidash.dev/humanize/social",
@ -227,7 +229,10 @@ void main() {
); );
expect( expect(
substituteHttpRequestModel( substituteHttpRequestModel(
httpRequestModel, envMap, activeEnvironmentId), httpRequestModel,
envMap,
activeEnvironmentId,
),
expected); expected);
}); });
@ -260,7 +265,10 @@ void main() {
httpRequestModel, envMap, activeEnvironmentId), httpRequestModel, envMap, activeEnvironmentId),
expected); expected);
}); });
test("Testing substituteHttpRequestModel with environment variables in body", () {
test(
"Testing substituteHttpRequestModel with environment variables in body",
() {
const httpRequestModel = HttpRequestModel( const httpRequestModel = HttpRequestModel(
url: "{{url}}/humanize/social", url: "{{url}}/humanize/social",
headers: [ headers: [
@ -287,7 +295,8 @@ void main() {
body: "The API key is token and the number is 8940000", body: "The API key is token and the number is 8940000",
); );
expect( expect(
substituteHttpRequestModel(httpRequestModel, envMap, activeEnvironmentId), substituteHttpRequestModel(
httpRequestModel, envMap, activeEnvironmentId),
expected); expected);
}); });
}); });