Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Dec 20, 2024. It is now read-only.

Commit df222f9

Browse filesBrowse files
authored
Merge pull request #1258 from Hellcatlk/UnitTest
add unit test for client/httputils.go
2 parents 79fd076 + 9abd23a commit df222f9
Copy full SHA for df222f9

File tree

Expand file treeCollapse file tree

1 file changed

+54
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+54
-0
lines changed
Open diff view settings
Collapse file

‎client/httpuils_test.go‎

Copy file name to clipboard
+54Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright The Dragonfly Authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package client
18+
19+
import (
20+
"errors"
21+
"testing"
22+
)
23+
24+
func TestParseHost(t *testing.T) {
25+
tests := []struct {
26+
name string
27+
host string
28+
expect error
29+
}{
30+
{
31+
name: "http host",
32+
host: "http://github.com",
33+
expect: nil,
34+
},
35+
{
36+
name: "https host",
37+
host: "https://github.com",
38+
expect: nil,
39+
},
40+
{
41+
name: "not support url scheme",
42+
host: "wss://github.com",
43+
expect: errors.New("not support url scheme wss"),
44+
},
45+
}
46+
for _, tt := range tests {
47+
t.Run(tt.name, func(t *testing.T) {
48+
_, _, _, err := ParseHost(tt.host)
49+
if (nil == err) != (nil == tt.expect) {
50+
t.Errorf("expect: %v, got: %v\n", tt.expect, err)
51+
}
52+
})
53+
}
54+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.