summaryrefslogtreecommitdiff
path: root/tools/fetch_test.py
blob: 35118ab96aa40d8ab2478b7eea652a4107555a3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env python
# Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import os
import sys
import shutil

from http_server import spawn
from util import DenoTestCase, mkdtemp, tests_path, run_output, test_main


class FetchTest(DenoTestCase):
    def test_fetch(self):
        deno_dir = mkdtemp()
        try:
            t = os.path.join(tests_path, "006_url_imports.ts")
            output = run_output([self.deno_exe, "fetch", t],
                                merge_env={"DENO_DIR": deno_dir})
            assert output == ""
            # Check that we actually did the prefetch.
            os.path.exists(
                os.path.join(
                    deno_dir,
                    "deps/http/localhost_PORT4545/tests/subdir/mod2.ts"))
        finally:
            shutil.rmtree(deno_dir)


if __name__ == "__main__":
    with spawn():
        test_main()