local state: fix test with updated error message

This commit is contained in:
Frank Schroeder 2017-08-28 14:17:15 +02:00 committed by Frank Schröder
parent 37c8492e5e
commit 36677bc90d
2 changed files with 5 additions and 5 deletions

View File

@ -348,7 +348,7 @@ func (l *State) AddCheck(check *structs.HealthCheck, token string) error {
// if there is a serviceID associated with the check, make sure it exists before adding it // if there is a serviceID associated with the check, make sure it exists before adding it
// NOTE - This logic may be moved to be handled within the Agent's Addcheck method after a refactor // NOTE - This logic may be moved to be handled within the Agent's Addcheck method after a refactor
if check.ServiceID != "" && l.services[check.ServiceID] == nil { if check.ServiceID != "" && l.services[check.ServiceID] == nil {
return fmt.Errorf("Check %q refers to non-existent service %q does not exist", check.CheckID, check.ServiceID) return fmt.Errorf("Check %q refers to non-existent service %q", check.CheckID, check.ServiceID)
} }
// hard-set the node name // hard-set the node name

View File

@ -1,6 +1,7 @@
package local_test package local_test
import ( import (
"errors"
"fmt" "fmt"
"reflect" "reflect"
"testing" "testing"
@ -1453,11 +1454,10 @@ func TestAgent_AddCheckFailure(t *testing.T) {
ServiceID: "redis", ServiceID: "redis",
Status: api.HealthPassing, Status: api.HealthPassing,
} }
expectedErr := "ServiceID \"redis\" does not exist" wantErr := errors.New(`Check "redis:1" refers to non-existent service "redis"`)
if err := l.AddCheck(chk, ""); err == nil || expectedErr != err.Error() { if got, want := l.AddCheck(chk, ""), wantErr; !reflect.DeepEqual(got, want) {
t.Fatalf("Expected error when adding a check for a non-existent service but got %v", err) t.Fatalf("got error %q want %q", got, want)
} }
} }
func TestAgent_sendCoordinate(t *testing.T) { func TestAgent_sendCoordinate(t *testing.T) {