Parcourir la source

Add test for new debug call and test helpers

pull/16/head
Kristijan Mitrovic il y a 4 ans
Parent
révision
99dfd4888c
2 fichiers modifiés avec 62 ajouts et 0 suppressions
  1. +14
    -0
      bubble-server/src/test/java/bubble/test/DebugCallsTest.java
  2. +48
    -0
      bubble-server/src/test/resources/models/tests/debug_echo.json

+ 14
- 0
bubble-server/src/test/java/bubble/test/DebugCallsTest.java Voir le fichier

@@ -0,0 +1,14 @@
/**
* Copyright (c) 2020 Bubble, Inc. All rights reserved.
* For personal (non-commercial) use, see license: https://getbubblenow.com/bubble-license/
*/
package bubble.test;

import org.junit.Test;

public class DebugCallsTest extends ActivatedBubbleModelTestBase {

@Override protected String getManifest() { return "manifest-empty"; }

@Test public void testEcho() throws Exception { modelTest("debug_echo"); }
}

+ 48
- 0
bubble-server/src/test/resources/models/tests/debug_echo.json Voir le fichier

@@ -0,0 +1,48 @@
[
{
"comment": "Simplest example of using ECHO debug call without the query param",
"request": { "uri": "debug/echo", "entity": { "anything": "something" } },
"response": { "check": [{ "condition": "len(json) == 0" }] },
"after": "add_to_ctx { \"added\": \"val\", \"addedInner\": { \"inner\": \"value\", \"another\": \"variable\" }, \"addedArray\": [ \"abc\", \"def\" ] }"
},

{
"comment": "Example of using ECHO debug call and echo_in_log after",
"request": {
"uri": "debug/echo?respondWith=inner.comment",
"entity": {
"inner": { "comment": "Fixed text comment" },
"non-existing": "{{notexistingvar}}"
}
},
"response": {
"raw": true,
"store": "echoedResponse",
"check": [{ "condition": "response.json == 'Fixed text comment'" }]
},
"after": "echo_in_log Test:\n\tnon existent value: {{somethingThatDoesntExist}}\n\tjust stored response: {{echoedResponse}}"
},

{
"comment": "Another example of using ECHO debug call and echo_in_log after",
"before": "add_to_ctx { \"brand\": \"new\" }",
"request": {
"uri": "debug/echo?respondWith=inner",
"entity": {
"previouslyStored": "{{echoedResponse}}",
"inner": { "comment": "Another fixed text comment" }
}
},
"response": {
"store": "echoedJson",
"check": [
{ "condition": "json.get('comment') == 'Another fixed text comment'" },
{ "condition": "'{{brand}}' == 'new'" },
{ "condition": "'{{addedInner.another}}' == 'variable'" },
{ "condition": "'{{added}}' == 'val'" }
]
},
"after": "echo_in_log \"And now the stored value is: {{echoedJson.comment}}\""
// echo_in_log is, of course, available within `before` also
}
]

Chargement…
Annuler
Enregistrer