Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Signed-off-by: Brandon Forster <me@brandonforster.com>
  • Loading branch information
brandonforster committed Jan 16, 2020
1 parent 6abf550 commit ebe72d7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 26 deletions.
12 changes: 2 additions & 10 deletions clients/urlclient/local_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package urlclient

import (
"reflect"
"testing"

"github.com/edgexfoundry/go-mod-core-contracts/clients/types"
Expand All @@ -27,20 +26,13 @@ func TestNewLocalClient(t *testing.T) {
if actualClient == nil {
t.Fatal("nil returned from newLocalClient")
}

expectedType := reflect.TypeOf(&localClient{})
clientType := reflect.TypeOf(actualClient)

if clientType != expectedType {
t.Fatalf("expected type %T, found %T", expectedType, actualClient)
}
}

func TestLocalClient_URLPrefix(t *testing.T) {
expectedURL := "http://domain.com"
client := newLocalClient(types.EndpointParams{Url: expectedURL})
urlClient := newLocalClient(types.EndpointParams{Url: expectedURL})

actualURL, err := client.Prefix()
actualURL, err := urlClient.Prefix()

if err != nil {
t.Fatalf("unexpected error %s", err.Error())
Expand Down
24 changes: 8 additions & 16 deletions clients/urlclient/registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package urlclient

import (
"fmt"
"reflect"
"testing"
"time"

Expand All @@ -29,20 +28,13 @@ func TestNewRegistryClient(t *testing.T) {
if actualClient == nil {
t.Fatal("nil returned from newRegistryClient")
}

expectedType := reflect.TypeOf(&registryClient{})
clientType := reflect.TypeOf(actualClient)

if clientType != expectedType {
t.Fatalf("expected type %T, found %T", expectedType, actualClient)
}
}

func TestRegistryClient_URLPrefix(t *testing.T) {
expectedURL := "http://domain.com"
client := newRegistryClient(types.EndpointParams{}, mockEndpoint{}, 100)
urlClient := newRegistryClient(types.EndpointParams{}, mockEndpoint{}, 100)

actualURL, err := client.Prefix()
actualURL, err := urlClient.Prefix()

if err != nil {
t.Fatalf("unexpected error %s", err.Error())
Expand All @@ -55,11 +47,11 @@ func TestRegistryClient_URLPrefix(t *testing.T) {

func TestRegistryClient_URLPrefixInitialized(t *testing.T) {
expectedURL := "http://domain.com"
client := newRegistryClient(types.EndpointParams{}, mockEndpoint{}, 100)
client.initialized = true
client.url = expectedURL
urlClient := newRegistryClient(types.EndpointParams{}, mockEndpoint{}, 100)
urlClient.initialized = true
urlClient.url = expectedURL

actualURL, err := client.Prefix()
actualURL, err := urlClient.Prefix()

if err != nil {
t.Fatalf("unexpected error %s", err.Error())
Expand All @@ -71,9 +63,9 @@ func TestRegistryClient_URLPrefixInitialized(t *testing.T) {
}

func TestRegistryClient_URLPrefix_TimedOut(t *testing.T) {
client := newRegistryClient(types.EndpointParams{}, mockTimeoutEndpoint{}, 1)
urlClient := newRegistryClient(types.EndpointParams{}, mockTimeoutEndpoint{}, 1)

actualURL, err := client.Prefix()
actualURL, err := urlClient.Prefix()

if err == nil || actualURL != "" {
t.Fatal("expected error")
Expand Down

0 comments on commit ebe72d7

Please sign in to comment.