File tree 2 files changed +3
-15
lines changed
2 files changed +3
-15
lines changed Original file line number Diff line number Diff line change 1
1
package main
2
2
3
3
import (
4
- "net/url"
5
4
"strings"
6
5
7
6
"github.com/hashicorp/consul/api"
@@ -14,15 +13,10 @@ type Consul struct {
14
13
15
14
// NewConsul returns a new instance of the Consul client using the given address
16
15
func NewConsul (addr string ) (* Consul , error ) {
17
- a , err := url .Parse (addr )
18
- if err != nil {
19
- return nil , err
20
- }
16
+ cfg := api .DefaultConfig ()
17
+ cfg .Address = addr
21
18
22
- c , err := api .NewClient (& api.Config {
23
- Address : a .Host ,
24
- Scheme : a .Scheme ,
25
- })
19
+ c , err := api .NewClient (cfg )
26
20
if err != nil {
27
21
return nil , err
28
22
}
Original file line number Diff line number Diff line change @@ -6,12 +6,6 @@ import (
6
6
"github.com/stretchr/testify/assert"
7
7
)
8
8
9
- func TestNewConsul (t * testing.T ) {
10
- c , err := NewConsul ("foo:b\a r;baz" )
11
- assert .Nil (t , c )
12
- assert .ErrorContains (t , err , "parse" )
13
- }
14
-
15
9
func TestConsulKey (t * testing.T ) {
16
10
assert .Equal (t , consulKey ("foo/bar/baz" ), "BAZ" )
17
11
assert .Equal (t , consulKey ("test" ), "TEST" )
You can’t perform that action at this time.
0 commit comments