Skip to content
This repository was archived by the owner on Dec 20, 2024. It is now read-only.

Commit 6da8759

Browse files
committed
add unit test cases
Signed-off-by: ZouYu <[email protected]>
1 parent 2af6a81 commit 6da8759

File tree

3 files changed

+31
-14
lines changed

3 files changed

+31
-14
lines changed

client/httpuils_test.go

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,31 +23,41 @@ import (
2323

2424
func TestParseHost(t *testing.T) {
2525
tests := []struct {
26-
name string
27-
host string
28-
expect error
26+
name string
27+
host string
28+
expected error
2929
}{
3030
{
31-
name: "http host",
32-
host: "http://github.com",
33-
expect: nil,
31+
name: "tcp host",
32+
host: "tcp://github.com",
33+
expected: nil,
3434
},
3535
{
36-
name: "https host",
37-
host: "https://github.com",
38-
expect: nil,
36+
name: "unix host",
37+
host: "unix://github.com",
38+
expected: nil,
3939
},
4040
{
41-
name: "not support url scheme",
42-
host: "wss://github.com",
43-
expect: errors.New("not support url scheme wss"),
41+
name: "http host",
42+
host: "http://github.com",
43+
expected: nil,
44+
},
45+
{
46+
name: "https host",
47+
host: "https://github.com",
48+
expected: nil,
49+
},
50+
{
51+
name: "not support url scheme",
52+
host: "wss://github.com",
53+
expected: errors.New("not support url scheme wss"),
4454
},
4555
}
4656
for _, tt := range tests {
4757
t.Run(tt.name, func(t *testing.T) {
4858
_, _, _, err := ParseHost(tt.host)
49-
if (nil == err) != (nil == tt.expect) {
50-
t.Errorf("expect: %v, got: %v\n", tt.expect, err)
59+
if (nil == err) != (nil == tt.expected) {
60+
t.Errorf("expected: %v, got: %v\n", tt.expected, err)
5161
}
5262
})
5363
}

dfget/core/api/download_api_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ func (s *DownloadAPITestSuite) TestGetRealRange(c *check.C) {
3636
rangeValue string
3737
expected string
3838
}{
39+
{"", "0-1", ""},
3940
{"0-1", "", "0-1"},
4041
{"0-1", "1-100", "1-2"},
4142
{"0-100", "1-100", "1-100"},

pkg/atomiccount/atomiccount_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ func (suite *AtomicCountUtilSuite) TestAdd(c *check.C) {
3939

4040
result := acount.Get()
4141
c.Check(result, check.Equals, (int32)(12))
42+
43+
var nilAcount *AtomicInt
44+
c.Check(nilAcount.Add(5), check.Equals, (int32)(0))
4245
}
4346

4447
func (suite *AtomicCountUtilSuite) TestSet(c *check.C) {
@@ -49,4 +52,7 @@ func (suite *AtomicCountUtilSuite) TestSet(c *check.C) {
4952
_ = acount.Set(1)
5053
result := acount.Get()
5154
c.Check(result, check.Equals, (int32)(1))
55+
56+
var nilAcount *AtomicInt
57+
c.Check(nilAcount.Get(), check.Equals, (int32)(0))
5258
}

0 commit comments

Comments
 (0)