Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

Commit

Permalink
add unit test for client/httputils.go
Browse files Browse the repository at this point in the history
Signed-off-by: ZouYu <[email protected]>
  • Loading branch information
zouy414 committed Mar 24, 2020
1 parent bae7528 commit 9abd23a
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions client/httpuils_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright The Dragonfly Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package client

import (
"errors"
"testing"
)

func TestParseHost(t *testing.T) {
tests := []struct {
name string
host string
expect error
}{
{
name: "http host",
host: "http://github.com",
expect: nil,
},
{
name: "https host",
host: "https://github.com",
expect: nil,
},
{
name: "not support url scheme",
host: "wss://github.com",
expect: errors.New("not support url scheme wss"),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
_, _, _, err := ParseHost(tt.host)
if (nil == err) != (nil == tt.expect) {
t.Errorf("expect: %v, got: %v\n", tt.expect, err)
}
})
}
}

0 comments on commit 9abd23a

Please sign in to comment.