Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
github
hub
提交
3b8e26d5
H
hub
项目概览
github
/
hub
12 个月 前同步成功
通知
3
Star
22523
Fork
2406
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hub
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3b8e26d5
编写于
11月 22, 2014
作者:
J
Jingwen Owen Ou
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #694 from github/windows_go_test_fix
Fix Go tests on Windows
上级
f5a140f0
44d1fa7f
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
66 addition
and
21 deletion
+66
-21
commands/runner_test.go
commands/runner_test.go
+3
-2
fixtures/test_repo.go
fixtures/test_repo.go
+4
-3
git/url.go
git/url.go
+5
-2
git/url_test.go
git/url_test.go
+44
-11
github/editor_test.go
github/editor_test.go
+7
-2
github/localrepo_test.go
github/localrepo_test.go
+3
-1
未找到文件。
commands/runner_test.go
浏览文件 @
3b8e26d5
package
commands
import
(
"github.com/bmizerany/assert"
"testing"
"github.com/bmizerany/assert"
)
func
TestRunner_splitAliasCmd
(
t
*
testing
.
T
)
{
...
...
@@ -29,7 +30,7 @@ func TestRunnerCallCommands(t *testing.T) {
var
result
string
f
:=
func
(
c
*
Command
,
args
*
Args
)
{
result
=
args
.
FirstParam
()
args
.
Replace
(
"
echo"
,
""
,
"true
"
)
args
.
Replace
(
"
git"
,
"version"
,
"
"
)
}
r
:=
NewRunner
()
...
...
fixtures/test_repo.go
浏览文件 @
3b8e26d5
...
...
@@ -57,17 +57,18 @@ func (r *TestRepo) clone(repo, dir string) error {
}
func
(
r
*
TestRepo
)
TearDown
()
{
err
:=
os
.
RemoveAll
(
r
.
dir
)
err
:=
os
.
Chdir
(
r
.
pwd
)
if
err
!=
nil
{
panic
(
err
)
}
err
=
os
.
Chdir
(
r
.
pwd
)
os
.
Setenv
(
"HOME"
,
r
.
home
)
err
=
os
.
RemoveAll
(
r
.
dir
)
if
err
!=
nil
{
panic
(
err
)
}
os
.
Setenv
(
"HOME"
,
r
.
home
)
}
func
SetupTestRepo
()
*
TestRepo
{
...
...
git/url.go
浏览文件 @
3b8e26d5
...
...
@@ -16,7 +16,10 @@ type URLParser struct {
}
func
(
p
*
URLParser
)
Parse
(
rawURL
string
)
(
u
*
url
.
URL
,
err
error
)
{
if
!
protocolRe
.
MatchString
(
rawURL
)
&&
strings
.
Contains
(
rawURL
,
":"
)
{
if
!
protocolRe
.
MatchString
(
rawURL
)
&&
strings
.
Contains
(
rawURL
,
":"
)
&&
// not a Windows path
!
strings
.
Contains
(
rawURL
,
"
\\
"
)
{
rawURL
=
"ssh://"
+
strings
.
Replace
(
rawURL
,
":"
,
"/"
,
1
)
}
...
...
@@ -25,7 +28,7 @@ func (p *URLParser) Parse(rawURL string) (u *url.URL, err error) {
return
}
if
u
.
Scheme
==
"http"
||
u
.
Scheme
==
"https
"
{
if
u
.
Scheme
!=
"ssh
"
{
return
}
...
...
git/url_test.go
浏览文件 @
3b8e26d5
...
...
@@ -6,32 +6,34 @@ import (
"github.com/bmizerany/assert"
)
func
TestURLParser_ParseURL
(
t
*
testing
.
T
)
{
func
createURLParser
()
*
URLParser
{
c
:=
make
(
SSHConfig
)
c
[
"github.com"
]
=
"ssh.github.com"
c
[
"gh"
]
=
"github.com"
c
[
"git.company.com"
]
=
"ssh.git.company.com"
p
:=
&
URLParser
{
c
}
return
&
URLParser
{
c
}
}
func
TestURLParser_ParseURL_HTTPURL
(
t
*
testing
.
T
)
{
p
:=
createURLParser
()
u
,
err
:=
p
.
Parse
(
"https://github.com/octokit/go-octokit.git"
)
assert
.
Equal
(
t
,
nil
,
err
)
assert
.
Equal
(
t
,
"github.com"
,
u
.
Host
)
assert
.
Equal
(
t
,
"https"
,
u
.
Scheme
)
assert
.
Equal
(
t
,
"/octokit/go-octokit.git"
,
u
.
Path
)
}
func
TestURLParser_ParseURL_GitURL
(
t
*
testing
.
T
)
{
p
:=
createURLParser
()
u
,
err
=
p
.
Parse
(
"git://github.com/octokit/go-octokit.git"
)
u
,
err
:
=
p
.
Parse
(
"git://github.com/octokit/go-octokit.git"
)
assert
.
Equal
(
t
,
nil
,
err
)
assert
.
Equal
(
t
,
"github.com"
,
u
.
Host
)
assert
.
Equal
(
t
,
"git"
,
u
.
Scheme
)
assert
.
Equal
(
t
,
"/octokit/go-octokit.git"
,
u
.
Path
)
u
,
err
=
p
.
Parse
(
"git@github.com:lostisland/go-sawyer.git"
)
assert
.
Equal
(
t
,
nil
,
err
)
assert
.
Equal
(
t
,
"github.com"
,
u
.
Host
)
assert
.
Equal
(
t
,
"ssh"
,
u
.
Scheme
)
assert
.
Equal
(
t
,
"git"
,
u
.
User
.
Username
())
assert
.
Equal
(
t
,
"/lostisland/go-sawyer.git"
,
u
.
Path
)
u
,
err
=
p
.
Parse
(
"https://git.company.com/octokit/go-octokit.git"
)
assert
.
Equal
(
t
,
nil
,
err
)
assert
.
Equal
(
t
,
"git.company.com"
,
u
.
Host
)
...
...
@@ -40,9 +42,26 @@ func TestURLParser_ParseURL(t *testing.T) {
u
,
err
=
p
.
Parse
(
"git://git.company.com/octokit/go-octokit.git"
)
assert
.
Equal
(
t
,
nil
,
err
)
assert
.
Equal
(
t
,
"
ssh.
git.company.com"
,
u
.
Host
)
assert
.
Equal
(
t
,
"git.company.com"
,
u
.
Host
)
assert
.
Equal
(
t
,
"git"
,
u
.
Scheme
)
assert
.
Equal
(
t
,
"/octokit/go-octokit.git"
,
u
.
Path
)
}
func
TestURLParser_ParseURL_SSHURL
(
t
*
testing
.
T
)
{
p
:=
createURLParser
()
u
,
err
:=
p
.
Parse
(
"git@github.com:lostisland/go-sawyer.git"
)
assert
.
Equal
(
t
,
nil
,
err
)
assert
.
Equal
(
t
,
"github.com"
,
u
.
Host
)
assert
.
Equal
(
t
,
"ssh"
,
u
.
Scheme
)
assert
.
Equal
(
t
,
"git"
,
u
.
User
.
Username
())
assert
.
Equal
(
t
,
"/lostisland/go-sawyer.git"
,
u
.
Path
)
u
,
err
=
p
.
Parse
(
"gh:octokit/go-octokit"
)
assert
.
Equal
(
t
,
nil
,
err
)
assert
.
Equal
(
t
,
"github.com"
,
u
.
Host
)
assert
.
Equal
(
t
,
"ssh"
,
u
.
Scheme
)
assert
.
Equal
(
t
,
"/octokit/go-octokit"
,
u
.
Path
)
u
,
err
=
p
.
Parse
(
"git@git.company.com:octokit/go-octokit"
)
assert
.
Equal
(
t
,
nil
,
err
)
...
...
@@ -50,3 +69,17 @@ func TestURLParser_ParseURL(t *testing.T) {
assert
.
Equal
(
t
,
"ssh"
,
u
.
Scheme
)
assert
.
Equal
(
t
,
"/octokit/go-octokit"
,
u
.
Path
)
}
func
TestURLParser_ParseURL_LocalPath
(
t
*
testing
.
T
)
{
p
:=
createURLParser
()
u
,
err
:=
p
.
Parse
(
"/path/to/repo.git"
)
assert
.
Equal
(
t
,
nil
,
err
)
assert
.
Equal
(
t
,
""
,
u
.
Host
)
assert
.
Equal
(
t
,
""
,
u
.
Scheme
)
assert
.
Equal
(
t
,
"/path/to/repo.git"
,
u
.
Path
)
u
,
err
=
p
.
Parse
(
`c:\path\to\repo.git`
)
assert
.
Equal
(
t
,
nil
,
err
)
assert
.
Equal
(
t
,
`c:\path\to\repo.git`
,
u
.
String
())
}
github/editor_test.go
浏览文件 @
3b8e26d5
...
...
@@ -14,6 +14,8 @@ import (
func
TestEditor_openAndEdit_deleteFileWhenOpeningEditorFails
(
t
*
testing
.
T
)
{
tempFile
,
_
:=
ioutil
.
TempFile
(
""
,
"editor-test"
)
tempFile
.
Close
()
ioutil
.
WriteFile
(
tempFile
.
Name
(),
[]
byte
(
"hello"
),
0644
)
editor
:=
Editor
{
Program
:
"memory"
,
...
...
@@ -26,10 +28,13 @@ func TestEditor_openAndEdit_deleteFileWhenOpeningEditorFails(t *testing.T) {
},
}
_
,
err
:=
editor
.
openAndEdit
()
assert
.
NotEqual
(
t
,
nil
,
err
)
_
,
err
:=
os
.
Stat
(
tempFile
.
Name
())
assert
.
Equal
(
t
,
nil
,
err
)
_
,
err
=
editor
.
openAndEdit
()
assert
.
Equal
(
t
,
"error using text editor for test message"
,
fmt
.
Sprintf
(
"%s"
,
err
))
// file is removed if there's error
_
,
err
=
os
.
Stat
(
tempFile
.
Name
())
assert
.
T
(
t
,
os
.
IsNotExist
(
err
))
}
...
...
github/localrepo_test.go
浏览文件 @
3b8e26d5
...
...
@@ -15,7 +15,9 @@ func TestGitHubRepo_OriginRemote(t *testing.T) {
localRepo
,
_
:=
LocalRepo
()
gitRemote
,
_
:=
localRepo
.
OriginRemote
()
assert
.
Equal
(
t
,
"origin"
,
gitRemote
.
Name
)
assert
.
Equal
(
t
,
repo
.
Remote
,
gitRemote
.
URL
.
String
())
u
,
_
:=
url
.
Parse
(
repo
.
Remote
)
assert
.
Equal
(
t
,
u
,
gitRemote
.
URL
)
}
func
TestGitHubRepo_remotesForPublish
(
t
*
testing
.
T
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录