Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
doodoocoder
prometheus
提交
df7cc4df
P
prometheus
项目概览
doodoocoder
/
prometheus
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
prometheus
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
df7cc4df
编写于
12月 08, 2017
作者:
C
Callum Styan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove Nil/NotNil functions
上级
ff0b0ac4
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
9 addition
and
71 deletion
+9
-71
head_test.go
head_test.go
+7
-7
postings_test.go
postings_test.go
+2
-2
testutil/testutil.go
testutil/testutil.go
+0
-62
未找到文件。
head_test.go
浏览文件 @
df7cc4df
...
...
@@ -204,8 +204,8 @@ func TestHead_Truncate(t *testing.T) {
{
minTime
:
3000
,
maxTime
:
3999
},
},
h
.
series
.
getByID
(
s2
.
ref
)
.
chunks
)
testutil
.
Nil
(
t
,
h
.
series
.
getByID
(
s3
.
ref
)
,
""
)
testutil
.
Nil
(
t
,
h
.
series
.
getByID
(
s4
.
ref
)
,
""
)
testutil
.
Assert
(
t
,
h
.
series
.
getByID
(
s3
.
ref
)
==
nil
,
""
)
testutil
.
Assert
(
t
,
h
.
series
.
getByID
(
s4
.
ref
)
==
nil
,
""
)
postingsA1
,
_
:=
expandPostings
(
h
.
postings
.
get
(
"a"
,
"1"
))
postingsA2
,
_
:=
expandPostings
(
h
.
postings
.
get
(
"a"
,
"2"
))
...
...
@@ -218,8 +218,8 @@ func TestHead_Truncate(t *testing.T) {
testutil
.
Equals
(
t
,
[]
uint64
{
s2
.
ref
},
postingsA2
)
testutil
.
Equals
(
t
,
[]
uint64
{
s1
.
ref
,
s2
.
ref
},
postingsB1
)
testutil
.
Equals
(
t
,
[]
uint64
{
s1
.
ref
,
s2
.
ref
},
postingsAll
)
testutil
.
Nil
(
t
,
postingsB2
,
""
)
testutil
.
Nil
(
t
,
postingsC1
,
""
)
testutil
.
Assert
(
t
,
postingsB2
==
nil
,
""
)
testutil
.
Assert
(
t
,
postingsC1
==
nil
,
""
)
testutil
.
Equals
(
t
,
map
[
string
]
struct
{}{
""
:
struct
{}{},
// from 'all' postings list
...
...
@@ -252,13 +252,13 @@ func TestMemSeries_truncateChunks(t *testing.T) {
lastID
:=
s
.
chunkID
(
countBefore
-
1
)
lastChunk
:=
s
.
chunk
(
lastID
)
testutil
.
NotNil
(
t
,
s
.
chunk
(
0
)
,
""
)
testutil
.
NotNil
(
t
,
lastChunk
,
""
)
testutil
.
Assert
(
t
,
s
.
chunk
(
0
)
!=
nil
,
""
)
testutil
.
Assert
(
t
,
lastChunk
!=
nil
,
""
)
s
.
truncateChunksBefore
(
2000
)
testutil
.
Equals
(
t
,
int64
(
2000
),
s
.
chunks
[
0
]
.
minTime
)
testutil
.
Nil
(
t
,
s
.
chunk
(
0
)
,
"first chunks not gone"
)
testutil
.
Assert
(
t
,
s
.
chunk
(
0
)
==
nil
,
"first chunks not gone"
)
testutil
.
Equals
(
t
,
countBefore
/
2
,
len
(
s
.
chunks
))
testutil
.
Equals
(
t
,
lastChunk
,
s
.
chunk
(
lastID
))
...
...
postings_test.go
浏览文件 @
df7cc4df
...
...
@@ -324,7 +324,7 @@ func TestBigEndian(t *testing.T) {
}
testutil
.
Assert
(
t
,
bep
.
Next
()
==
false
,
""
)
testutil
.
Nil
(
t
,
bep
.
Err
()
,
""
)
testutil
.
Assert
(
t
,
bep
.
Err
()
==
nil
,
""
)
})
t
.
Run
(
"Seek"
,
func
(
t
*
testing
.
T
)
{
...
...
@@ -370,7 +370,7 @@ func TestBigEndian(t *testing.T) {
for
_
,
v
:=
range
table
{
testutil
.
Equals
(
t
,
v
.
found
,
bep
.
Seek
(
uint64
(
v
.
seek
)))
testutil
.
Equals
(
t
,
uint64
(
v
.
val
),
bep
.
At
())
testutil
.
Nil
(
t
,
bep
.
Err
()
,
""
)
testutil
.
Assert
(
t
,
bep
.
Err
()
==
nil
,
""
)
}
})
}
...
...
testutil/testutil.go
浏览文件 @
df7cc4df
...
...
@@ -65,65 +65,3 @@ func Equals(tb testing.TB, exp, act interface{}) {
tb
.
FailNow
()
}
}
// from stretchr/testify
// Copyright (c) 2012 - 2013 Mat Ryer and Tyler Bunnell
// Please consider promoting this project if you find it useful.
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
// OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
// OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// isNil checks if a specified object is nil or not, without Failing.
func
isNil
(
object
interface
{})
bool
{
if
object
==
nil
{
return
true
}
value
:=
reflect
.
ValueOf
(
object
)
kind
:=
value
.
Kind
()
if
kind
>=
reflect
.
Chan
&&
kind
<=
reflect
.
Slice
&&
value
.
IsNil
()
{
return
true
}
return
false
}
// modified from stretchr/testify
// Nil asserts that the specified object is nil.
//
// assert.Nil(t, err)
//
// Returns whether the assertion was successful (true) or not (false).
func
Nil
(
tb
testing
.
TB
,
object
interface
{},
msg
string
)
{
if
!
isNil
(
object
)
{
_
,
file
,
line
,
_
:=
runtime
.
Caller
(
1
)
fmt
.
Printf
(
"
\0
33[31m%s:%d:
\n\n\t
exp: %#v to be nil
\n\n\t
msg: %#v
\0
33[39m
\n\n
"
,
filepath
.
Base
(
file
),
line
,
object
,
msg
)
tb
.
FailNow
()
}
}
func
NotNil
(
tb
testing
.
TB
,
object
interface
{},
msg
string
)
{
if
isNil
(
object
)
{
_
,
file
,
line
,
_
:=
runtime
.
Caller
(
1
)
fmt
.
Printf
(
"
\0
33[31m%s:%d:
\n\n\t
exp: %#v to not be nil
\n\n\t
msg: %#v
\0
33[39m
\n\n
"
,
filepath
.
Base
(
file
),
line
,
object
,
msg
)
tb
.
FailNow
()
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录