|
11 | 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | 12 | # See the License for the specific language governing permissions and |
13 | 13 | # limitations under the License. |
| 14 | + |
| 15 | +import os |
14 | 16 | import pathlib |
15 | 17 | import re |
16 | 18 | import time |
@@ -318,3 +320,42 @@ def test_flask_current_app_is_available(): |
318 | 320 | resp = client.get("/") |
319 | 321 |
|
320 | 322 | assert resp.status_code == 200 |
| 323 | + |
| 324 | + |
| 325 | +def test_function_returns_none(): |
| 326 | + source = TEST_FUNCTIONS_DIR / "returns_none" / "main.py" |
| 327 | + target = "function" |
| 328 | + |
| 329 | + client = create_app(target, source).test_client() |
| 330 | + resp = client.get("/") |
| 331 | + |
| 332 | + assert resp.status_code == 500 |
| 333 | + |
| 334 | + |
| 335 | +def test_legacy_function_check_env(monkeypatch): |
| 336 | + source = TEST_FUNCTIONS_DIR / "http_check_env" / "main.py" |
| 337 | + target = "function" |
| 338 | + |
| 339 | + monkeypatch.setenv("ENTRY_POINT", target) |
| 340 | + |
| 341 | + client = create_app(target, source).test_client() |
| 342 | + resp = client.post("/", json={"mode": "FUNCTION_TRIGGER_TYPE"}) |
| 343 | + assert resp.status_code == 200 |
| 344 | + assert resp.data == b"http" |
| 345 | + |
| 346 | + resp = client.post("/", json={"mode": "FUNCTION_NAME"}) |
| 347 | + assert resp.status_code == 200 |
| 348 | + assert resp.data.decode("utf-8") == target |
| 349 | + |
| 350 | + |
| 351 | +def test_legacy_function_returns_none(monkeypatch): |
| 352 | + source = TEST_FUNCTIONS_DIR / "returns_none" / "main.py" |
| 353 | + target = "function" |
| 354 | + |
| 355 | + monkeypatch.setenv("ENTRY_POINT", target) |
| 356 | + |
| 357 | + client = create_app(target, source).test_client() |
| 358 | + resp = client.get("/") |
| 359 | + |
| 360 | + assert resp.status_code == 200 |
| 361 | + assert resp.data == b"OK" |
0 commit comments