Azure / InnovationEngine

An experiment in simplicity for complex environments
MIT License
34 stars 17 forks source link

[RFC] Add expected_contains tag #114

Closed eiffel-fl closed 10 months ago

eiffel-fl commented 11 months ago

Hi.

In this PR, I added a new expected_contains tag. This tag basically checks the output contains the given string, tutorial.md was updated to reflect this change:

$ ./bin/ie test tutorial.md
Welcome to the innovation Engine Tutorial
  1. Running simple bash commands
  ✔

  2. Test Code block with expected output
  ✔

  3. Test Code block contains expected output
  ✔

As a result, the test fails with the following patch applied:

diff --git a/tutorial.md b/tutorial.md
index 05751cc..756bcff 100644
--- a/tutorial.md
+++ b/tutorial.md
@@ -29,7 +29,7 @@ echo "Foo Bar"
 \`\`\`

 It also can test the output to make sure everything ran as planned.
-<!--expected_contains="Foo"-->
+<!--expected_contains="Quux"-->
 \`\`\`
 Foo Bar
 \`\`\`
$ ./bin/ie test tutorial.md
Welcome to the innovation Engine Tutorial
  1. Running simple bash commands
  ✔

  2. Test Code block with expected output
  ✔

  3. Test Code block contains expected output
  \Error when comparing the command outputs: %s
  ✔ ected output does not contain: "Quux".

If you see any way to improve this contribution, feel free to share.

Best regards and thank you in advance.

rgardler-msft commented 11 months ago

This applies to #14

eiffel-fl commented 11 months ago

On a side note, I am wondering if we cannot hide ExpectedRegex and ExpectedSimilarity in a golang equivalent to void * and casting it to the corresponding types in the latter function (of course exploding if we cannot cast to float or regex).