mirror of
https://github.com/status-im/consul.git
synced 2025-02-23 10:58:25 +00:00
consul/state: negative tests
This commit is contained in:
parent
77f14af977
commit
8c6f40f299
@ -278,6 +278,23 @@ func TestStateStore_DeleteNodeService(t *testing.T) {
|
|||||||
func TestStateStore_EnsureCheck(t *testing.T) {
|
func TestStateStore_EnsureCheck(t *testing.T) {
|
||||||
s := testStateStore(t)
|
s := testStateStore(t)
|
||||||
|
|
||||||
|
// Create a check associated with the node
|
||||||
|
check := &structs.HealthCheck{
|
||||||
|
Node: "node1",
|
||||||
|
CheckID: "check1",
|
||||||
|
Name: "redis check",
|
||||||
|
Status: structs.HealthPassing,
|
||||||
|
Notes: "test check",
|
||||||
|
Output: "aaa",
|
||||||
|
ServiceID: "service1",
|
||||||
|
ServiceName: "redis",
|
||||||
|
}
|
||||||
|
|
||||||
|
// Creating a check without a node returns error
|
||||||
|
if err := s.EnsureCheck(1, check); err != ErrMissingNode {
|
||||||
|
t.Fatalf("expected %#v, got: %#v", ErrMissingNode, err)
|
||||||
|
}
|
||||||
|
|
||||||
// Create a node and insert it
|
// Create a node and insert it
|
||||||
node := &structs.Node{
|
node := &structs.Node{
|
||||||
Node: "node1",
|
Node: "node1",
|
||||||
@ -287,6 +304,11 @@ func TestStateStore_EnsureCheck(t *testing.T) {
|
|||||||
t.Fatalf("err: %s", err)
|
t.Fatalf("err: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Creating a check with a bad services returns error
|
||||||
|
if err := s.EnsureCheck(1, check); err != ErrMissingService {
|
||||||
|
t.Fatalf("expected: %#v, got: %#v", ErrMissingService, err)
|
||||||
|
}
|
||||||
|
|
||||||
// Create a service and insert it
|
// Create a service and insert it
|
||||||
service := &structs.NodeService{
|
service := &structs.NodeService{
|
||||||
ID: "service1",
|
ID: "service1",
|
||||||
@ -299,17 +321,7 @@ func TestStateStore_EnsureCheck(t *testing.T) {
|
|||||||
t.Fatalf("err: %s", err)
|
t.Fatalf("err: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a check associated with the node and insert it
|
// Inserting the check with the prerequisites succeeds
|
||||||
check := &structs.HealthCheck{
|
|
||||||
Node: "node1",
|
|
||||||
CheckID: "check1",
|
|
||||||
Name: "redis check",
|
|
||||||
Status: structs.HealthPassing,
|
|
||||||
Notes: "test check",
|
|
||||||
Output: "aaa",
|
|
||||||
ServiceID: "service1",
|
|
||||||
ServiceName: "redis",
|
|
||||||
}
|
|
||||||
if err := s.EnsureCheck(3, check); err != nil {
|
if err := s.EnsureCheck(3, check); err != nil {
|
||||||
t.Fatalf("err: %s", err)
|
t.Fatalf("err: %s", err)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user