MCPcopy
hub / github.com/shyiko/jabba / TestBinJavaRelocation

Function TestBinJavaRelocation

command/install_test.go:10–80  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestBinJavaRelocation(t *testing.T) {
11 ok := func(err error) {
12 if err != nil {
13 t.Fatal(err)
14 }
15 }
16 nok := func(err error) {
17 if err == nil {
18 t.Fatal(err)
19 }
20 }
21 dir, err := ioutil.TempDir("", "install_test")
22 ok(err)
23 for _, scenario := range []struct {
24 os string
25 bin string
26 prefix string
27 paths []string
28 }{
29 {
30 os: "linux",
31 bin: "java",
32 prefix: "",
33 paths: []string{""},
34 },
35 {
36 os: "darwin",
37 bin: "java",
38 prefix: filepath.Join("Contents", "Home"),
39 paths: []string{
40 "",
41 filepath.Join("Home"),
42 filepath.Join("Contents", "Home"),
43 },
44 },
45 {
46 os: "windows",
47 bin: "java.exe",
48 prefix: "",
49 paths: []string{""},
50 },
51 } {
52 for _, p := range scenario.paths {
53 test1 := filepath.Join(dir, "test1")
54 ok(touch(test1, p, "bin", scenario.bin))
55 ok(normalizePathToBinJava(test1, scenario.os))
56 ok(file(test1, scenario.prefix, "bin", scenario.bin))
57
58 test2 := filepath.Join(dir, "test2")
59 ok(touch(test2, "subdir", p, "bin", scenario.bin))
60 ok(normalizePathToBinJava(test2, scenario.os))
61 ok(file(test2, scenario.prefix, "bin", scenario.bin))
62
63 test3 := filepath.Join(dir, "test3")
64 ok(touch(test3, "subdir", "subdir", p, "bin", scenario.bin))
65 ok(normalizePathToBinJava(test3, scenario.os))
66 ok(file(test3, scenario.prefix, "bin", scenario.bin))
67

Callers

nothing calls this directly

Calls 3

normalizePathToBinJavaFunction · 0.85
fileFunction · 0.85
touchFunction · 0.70

Tested by

no test coverage detected