|
12 | 12 | # See the License for the specific language governing permissions and |
13 | 13 | # limitations under the License. |
14 | 14 |
|
| 15 | +import os |
15 | 16 | import pathlib |
16 | 17 | import re |
17 | 18 | import time |
@@ -455,3 +456,42 @@ def test_class_in_main_is_in_right_module(): |
455 | 456 | resp = client.get("/") |
456 | 457 |
|
457 | 458 | assert resp.status_code == 200 |
| 459 | + |
| 460 | + |
| 461 | +def test_function_returns_none(): |
| 462 | + source = TEST_FUNCTIONS_DIR / "returns_none" / "main.py" |
| 463 | + target = "function" |
| 464 | + |
| 465 | + client = create_app(target, source).test_client() |
| 466 | + resp = client.get("/") |
| 467 | + |
| 468 | + assert resp.status_code == 500 |
| 469 | + |
| 470 | + |
| 471 | +def test_legacy_function_check_env(monkeypatch): |
| 472 | + source = TEST_FUNCTIONS_DIR / "http_check_env" / "main.py" |
| 473 | + target = "function" |
| 474 | + |
| 475 | + monkeypatch.setenv("ENTRY_POINT", target) |
| 476 | + |
| 477 | + client = create_app(target, source).test_client() |
| 478 | + resp = client.post("/", json={"mode": "FUNCTION_TRIGGER_TYPE"}) |
| 479 | + assert resp.status_code == 200 |
| 480 | + assert resp.data == b"http" |
| 481 | + |
| 482 | + resp = client.post("/", json={"mode": "FUNCTION_NAME"}) |
| 483 | + assert resp.status_code == 200 |
| 484 | + assert resp.data.decode("utf-8") == target |
| 485 | + |
| 486 | + |
| 487 | +def test_legacy_function_returns_none(monkeypatch): |
| 488 | + source = TEST_FUNCTIONS_DIR / "returns_none" / "main.py" |
| 489 | + target = "function" |
| 490 | + |
| 491 | + monkeypatch.setenv("ENTRY_POINT", target) |
| 492 | + |
| 493 | + client = create_app(target, source).test_client() |
| 494 | + resp = client.get("/") |
| 495 | + |
| 496 | + assert resp.status_code == 200 |
| 497 | + assert resp.data == b"OK" |
0 commit comments