diff options
Diffstat (limited to 'os_test.go')
-rw-r--r-- | os_test.go | 43 |
1 files changed, 40 insertions, 3 deletions
diff --git a/os_test.go b/os_test.go index ac94b5a3c..7fefcad8c 100644 --- a/os_test.go +++ b/os_test.go @@ -11,7 +11,8 @@ func AssertEqual(t *testing.T, actual string, expected string) { } } -func TestResolveModule(t *testing.T) { +func TestResolveModule1(t *testing.T) { + createDirs() moduleName, filename, err := ResolveModule( "http://localhost:4545/testdata/subdir/print_hello.ts", "/Users/rld/go/src/github.com/ry/deno/testdata/006_url_imports.ts") @@ -22,8 +23,11 @@ func TestResolveModule(t *testing.T) { "http://localhost:4545/testdata/subdir/print_hello.ts") AssertEqual(t, filename, path.Join(SrcDir, "localhost:4545/testdata/subdir/print_hello.ts")) +} - moduleName, filename, err = ResolveModule( +func TestResolveModule2(t *testing.T) { + createDirs() + moduleName, filename, err := ResolveModule( "./subdir/print_hello.ts", "/Users/rld/go/src/github.com/ry/deno/testdata/006_url_imports.ts") if err != nil { @@ -33,10 +37,13 @@ func TestResolveModule(t *testing.T) { "/Users/rld/go/src/github.com/ry/deno/testdata/subdir/print_hello.ts") AssertEqual(t, filename, "/Users/rld/go/src/github.com/ry/deno/testdata/subdir/print_hello.ts") +} +func TestResolveModule3(t *testing.T) { + createDirs() // In the case where the containingFile is a directory (indicated with a // trailing slash) - moduleName, filename, err = ResolveModule( + moduleName, filename, err := ResolveModule( "testdata/001_hello.js", "/Users/rld/go/src/github.com/ry/deno/") if err != nil { @@ -47,3 +54,33 @@ func TestResolveModule(t *testing.T) { AssertEqual(t, filename, "/Users/rld/go/src/github.com/ry/deno/testdata/001_hello.js") } + +func TestResolveModule4(t *testing.T) { + createDirs() + // Files in SrcDir should resolve to URLs. + moduleName, filename, err := ResolveModule( + path.Join(SrcDir, "unpkg.com/liltest@0.0.5/index.ts"), + ".") + if err != nil { + t.Fatalf(err.Error()) + } + AssertEqual(t, moduleName, + "http://unpkg.com/liltest@0.0.5/index.ts") + AssertEqual(t, filename, + "/Users/rld/.deno/src/unpkg.com/liltest@0.0.5/index.ts") +} + +func TestResolveModule5(t *testing.T) { + createDirs() + // Files in SrcDir should resolve to URLs. + moduleName, filename, err := ResolveModule( + "./util", + path.Join(SrcDir, "unpkg.com/liltest@0.0.5/index.ts")) + if err != nil { + t.Fatalf(err.Error()) + } + AssertEqual(t, moduleName, + "http://unpkg.com/liltest@0.0.5/util.ts") + AssertEqual(t, filename, + path.Join(SrcDir, "unpkg.com/liltest@0.0.5/util.ts")) +} |