Add unit tests

This commit is contained in:
Mayuresh Gaitonde
2020-12-17 17:25:53 -08:00
parent 3702339f44
commit 6be4d69d02
705 changed files with 120529 additions and 150051 deletions

View File

@@ -3,12 +3,13 @@ package controller
import (
"encoding/json"
"fmt"
"github.com/golang/glog"
"net/http"
"net/url"
"os"
"strings"
"time"
"github.com/golang/glog"
)
const (
@@ -20,10 +21,18 @@ const (
localHealthCheckurl = "/agent/checks"
)
type Clienter interface {
Get(url string) (*http.Response, error)
}
type Client struct {
*http.Client
}
type ConsulMon struct {
addr string
node string
client *http.Client
client Clienter
}
type ConsulServiceData struct {
@@ -167,7 +176,7 @@ func (c *ConsulMon) healthCheckRemote(service string) (bool, error) {
// healthCheck determines if we should use the local agent
// If the address contains "localhost", then it presumes that the local agent is to be used.
func (c *ConsulMon) healthCheck(service string) (bool, error) {
usingLocalAgent := strings.Contains(c.addr, "localhost")
usingLocalAgent := strings.Contains(c.addr, "localhost") || strings.Contains(c.addr, "127.0.0.1")
if usingLocalAgent {
return c.healthCheckLocal(service)
}