-
Notifications
You must be signed in to change notification settings - Fork 115
/
gnvm_test.go
88 lines (79 loc) · 2.18 KB
/
gnvm_test.go
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package main
import (
"fmt"
"gnvm/nodehandle"
"gnvm/util"
"testing"
)
func TestCurl(t *testing.T) {
//testSearch()
//testNodist()
//testNPManage()
//testGetNPMVer()
testIsDirExist()
//testArch()
//testVaildPath()
}
func testSearch() {
nodehandle.Search("x.x.x")
nodehandle.Search("0.10.x")
nodehandle.Search("5.x.x")
nodehandle.Search("5.0.0")
nodehandle.Search(`/^5(\.([0]|[1-9]\d?)){2}$/`)
nodehandle.Search("latest")
nodehandle.Search("1.x.x")
nodehandle.Search("1.1.x")
nodehandle.Search("3.x.x")
nodehandle.Search("3.3.x")
}
func testNodist() {
if nl, err, code := nodehandle.New("http://npm.taobao.org/mirrors/iojs/index.json", nil); err != nil {
fmt.Println(err)
fmt.Println(code)
} else {
nl.Detail(0)
}
}
func testNPManage() {
name := `v3.8.5.zip`
npm := new(nodehandle.NPMange)
npm.New().CleanAll()
npm.SetZip(name)
npm.Unzip()
npm.Install()
fmt.Println(npm)
}
func testGetNPMVer() {
url := "http://npm.taobao.org/mirrors/node/index.json"
ver := "5.9.0"
if nd, err := nodehandle.FindNodeDetailByVer(url, ver); err == nil {
fmt.Println(nd)
}
}
func testIsDirExist() {
// empty
fmt.Println(util.IsDirExist(""))
// no exist
fmt.Println(util.IsDirExist(`C:\Users\Kenshin\Documents\DevTools\nodejss`))
fmt.Println(util.IsDirExist(`C:\Users\Kenshin\Documents\DevTools\nodejs\node_moduless\npm`))
fmt.Println(util.IsDirExist(`C:\Users\Kenshin\Documents\DevTools\nodejs\5.1.1\node.exe`))
// exist
fmt.Println(util.IsDirExist(`C:\Users\Kenshin\Documents\DevTools\nodejs`))
fmt.Println(util.IsDirExist(`C:\Users\Kenshin\Documents\DevTools\nodejs\node_modules`))
// not valid path
fmt.Println(util.IsDirExist("gnvm"))
// exist
fmt.Println(util.IsDirExist(`C:\Users\Kenshin\Documents\DevTools\nodejs\5.9.1\node.exe`))
fmt.Println(util.IsDirExist(`C:\Users\Kenshin\Documents\DevTools`, `nodejs`, `5.1.1`))
}
func testArch() {
bit32, _ := util.Arch(`C:\Users\Kenshin\Documents\DevTools\nodejs\5.1.1-x86\node.exe`)
fmt.Println(bit32)
bit64, _ := util.Arch(`C:\Users\Kenshin\Documents\DevTools\nodejs\5.1.1\node.exe`)
fmt.Println(bit64)
}
func testVaildPath() {
path := `C:\Users\Kenshin\Documents\DevTools\nodejs\5.1.1-x86\`
util.FormatPath(&path)
fmt.Println(path)
}