Skip to content

Commit 439d515

Browse files
committed
- Add Step information to environment set logger
- Minor doc updates Signed-off-by: Gopal S Akshintala <[email protected]>
1 parent 4060032 commit 439d515

File tree

3 files changed

+25
-7
lines changed

3 files changed

+25
-7
lines changed

README.adoc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ In the case of collision between variable keys, the precedence order to derive a
125125

126126
[.lead]
127127
You can _kick off_ this *Template-Driven Testing* by invoking `ReVoman.revUp()`,
128-
supplying your Postman templates and environments, and all your customizations through a configuration:
128+
supplying your Postman templates and environments, and all your customizations through a *Configuration*:
129129

130130
[source,java,indent=0,tabsize=2,options="nowrap"]
131131
----
@@ -337,6 +337,11 @@ include::{integrationtestdir}/com/salesforce/revoman/integration/core/pq/PQE2EWi
337337
<14> Run more assertions on the <<Rundown>>
338338
endif::[]
339339

340+
== Reuse Config
341+
342+
You can define a base common config and reuse it by overriding certain properties using the `override...()` methods,
343+
which are present for each config attribute
344+
340345
== Debugging UX
341346

342347
[.lead]
@@ -365,7 +370,8 @@ Here is the failure hierarchy of what can go wrong in this process
365370
image::failure-hierarchy.png[Failure Hierarchy]
366371

367372
[.lead]
368-
ReṼoman logs all the key operations that happen inside its source-code.
373+
ReṼoman logs all the key operations that happen inside its source-code,
374+
including how the environment variables are being mutated by a step in its <<Pre-req and Post-res scripts>>.
369375
Watch your console to check what's going on in the execution or troubleshoot from CI/CD logs
370376

371377
NOTE: link:docs/revoman.exe.log[📝Sample log] printed during execution

src/main/kotlin/com/salesforce/revoman/internal/postman/PostmanSDK.kt

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import com.salesforce.revoman.internal.postman.template.Url
1515
import com.salesforce.revoman.output.Rundown
1616
import com.salesforce.revoman.output.postman.PostmanEnvironment
1717
import com.salesforce.revoman.output.report.StepReport
18+
import io.exoquery.pprint
19+
import io.github.oshai.kotlinlogging.KotlinLogging
1820
import org.graalvm.polyglot.Context
1921
import org.graalvm.polyglot.HostAccess
2022
import org.graalvm.polyglot.Source
@@ -36,6 +38,7 @@ class PostmanSDK(
3638
lateinit var request: Request
3739
lateinit var response: Response
3840
lateinit var currentStepReport: StepReport
41+
@Suppress("unused")
3942
@JvmField val variables: Variables = Variables()
4043
lateinit var rundown: Rundown
4144
@JvmField val xml2Json = Xml2Json { xml -> moshiReVoman.asA(U.xmlToJson(xml)) }
@@ -112,14 +115,21 @@ class PostmanSDK(
112115
evaluateJS("jsonStr => JSON.parse(jsonStr)").execute(jsonStr)
113116

114117
inner class Variables {
115-
fun has(variableKey: String) = environment.containsKey(variableKey)
118+
fun has(key: String) = environment.containsKey(key)
119+
120+
fun get(key: String) = environment[key]
116121

117-
fun get(variableKey: String) = environment[variableKey]
122+
fun set(key: String, value: String) {
123+
logger.info { "pm environment variable set through JS in Step: ${currentStepReport.step} - key: $key, value: ${pprint(value)}" }
124+
environment.set(key, value)
125+
}
118126

119-
fun set(variableKey: String, value: String) {
120-
environment.set(variableKey, value)
127+
fun unset(key: String) {
128+
logger.info { "pm environment variable unset through JS in Step: ${currentStepReport.step} - key: $key" }
129+
environment.unset(key)
121130
}
122131

132+
@Suppress("unused")
123133
fun replaceIn(stringToReplace: String): String =
124134
regexReplacer.replaceVariablesRecursively(stringToReplace, this@PostmanSDK) ?: ""
125135
}
@@ -161,3 +171,5 @@ class PostmanSDK(
161171
}
162172

163173
data class Info(@JvmField val requestName: String)
174+
175+
private val logger = KotlinLogging.logger {}

src/main/kotlin/com/salesforce/revoman/output/postman/PostmanEnvironment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ constructor(
3232

3333
fun set(key: String, value: ValueT) {
3434
mutableEnv[key] = value
35-
logger.info { "pm environment variable set through JS - key: $key, value: ${pprint(value)}" }
35+
logger.info { "pm environment variable set - key: $key, value: ${pprint(value)}" }
3636
}
3737

3838
@Suppress("unused")

0 commit comments

Comments
 (0)