mirror of https://github.com/status-im/consul.git
consul/state: start tests for schema
This commit is contained in:
parent
89f87b7b5e
commit
8181be18f2
|
@ -68,6 +68,7 @@ func nodesTableSchema() *memdb.TableSchema {
|
||||||
Name: "nodes",
|
Name: "nodes",
|
||||||
Indexes: map[string]*memdb.IndexSchema{
|
Indexes: map[string]*memdb.IndexSchema{
|
||||||
"id": &memdb.IndexSchema{
|
"id": &memdb.IndexSchema{
|
||||||
|
Name: "id",
|
||||||
AllowMissing: false,
|
AllowMissing: false,
|
||||||
Unique: true,
|
Unique: true,
|
||||||
Indexer: &memdb.StringFieldIndex{
|
Indexer: &memdb.StringFieldIndex{
|
||||||
|
@ -86,6 +87,7 @@ func servicesTableSchema() *memdb.TableSchema {
|
||||||
Name: "services",
|
Name: "services",
|
||||||
Indexes: map[string]*memdb.IndexSchema{
|
Indexes: map[string]*memdb.IndexSchema{
|
||||||
"id": &memdb.IndexSchema{
|
"id": &memdb.IndexSchema{
|
||||||
|
Name: "id",
|
||||||
AllowMissing: false,
|
AllowMissing: false,
|
||||||
Unique: true,
|
Unique: true,
|
||||||
Indexer: &memdb.StringFieldIndex{
|
Indexer: &memdb.StringFieldIndex{
|
||||||
|
@ -94,6 +96,7 @@ func servicesTableSchema() *memdb.TableSchema {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"service": &memdb.IndexSchema{
|
"service": &memdb.IndexSchema{
|
||||||
|
Name: "service",
|
||||||
AllowMissing: true,
|
AllowMissing: true,
|
||||||
Unique: false,
|
Unique: false,
|
||||||
Indexer: &memdb.StringFieldIndex{
|
Indexer: &memdb.StringFieldIndex{
|
||||||
|
@ -114,6 +117,7 @@ func checksTableSchema() *memdb.TableSchema {
|
||||||
Name: "checks",
|
Name: "checks",
|
||||||
Indexes: map[string]*memdb.IndexSchema{
|
Indexes: map[string]*memdb.IndexSchema{
|
||||||
"id": &memdb.IndexSchema{
|
"id": &memdb.IndexSchema{
|
||||||
|
Name: "id",
|
||||||
AllowMissing: false,
|
AllowMissing: false,
|
||||||
Unique: true,
|
Unique: true,
|
||||||
Indexer: &memdb.CompoundIndex{
|
Indexer: &memdb.CompoundIndex{
|
||||||
|
@ -130,6 +134,7 @@ func checksTableSchema() *memdb.TableSchema {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"status": &memdb.IndexSchema{
|
"status": &memdb.IndexSchema{
|
||||||
|
Name: "status",
|
||||||
AllowMissing: false,
|
AllowMissing: false,
|
||||||
Unique: false,
|
Unique: false,
|
||||||
Indexer: &memdb.StringFieldIndex{
|
Indexer: &memdb.StringFieldIndex{
|
||||||
|
@ -138,6 +143,7 @@ func checksTableSchema() *memdb.TableSchema {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"service": &memdb.IndexSchema{
|
"service": &memdb.IndexSchema{
|
||||||
|
Name: "service",
|
||||||
AllowMissing: true,
|
AllowMissing: true,
|
||||||
Unique: false,
|
Unique: false,
|
||||||
Indexer: &memdb.StringFieldIndex{
|
Indexer: &memdb.StringFieldIndex{
|
||||||
|
@ -146,6 +152,7 @@ func checksTableSchema() *memdb.TableSchema {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"node": &memdb.IndexSchema{
|
"node": &memdb.IndexSchema{
|
||||||
|
Name: "node",
|
||||||
AllowMissing: true,
|
AllowMissing: true,
|
||||||
Unique: false,
|
Unique: false,
|
||||||
Indexer: &memdb.CompoundIndex{
|
Indexer: &memdb.CompoundIndex{
|
||||||
|
@ -175,6 +182,7 @@ func kvsTableSchema() *memdb.TableSchema {
|
||||||
Name: "kvs",
|
Name: "kvs",
|
||||||
Indexes: map[string]*memdb.IndexSchema{
|
Indexes: map[string]*memdb.IndexSchema{
|
||||||
"id": &memdb.IndexSchema{
|
"id": &memdb.IndexSchema{
|
||||||
|
Name: "id",
|
||||||
AllowMissing: false,
|
AllowMissing: false,
|
||||||
Unique: true,
|
Unique: true,
|
||||||
Indexer: &memdb.StringFieldIndex{
|
Indexer: &memdb.StringFieldIndex{
|
||||||
|
@ -183,6 +191,7 @@ func kvsTableSchema() *memdb.TableSchema {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"session": &memdb.IndexSchema{
|
"session": &memdb.IndexSchema{
|
||||||
|
Name: "session",
|
||||||
AllowMissing: true,
|
AllowMissing: true,
|
||||||
Unique: false,
|
Unique: false,
|
||||||
Indexer: &memdb.StringFieldIndex{
|
Indexer: &memdb.StringFieldIndex{
|
||||||
|
@ -202,6 +211,7 @@ func tombstonesTableSchema() *memdb.TableSchema {
|
||||||
Name: "tombstones",
|
Name: "tombstones",
|
||||||
Indexes: map[string]*memdb.IndexSchema{
|
Indexes: map[string]*memdb.IndexSchema{
|
||||||
"id": &memdb.IndexSchema{
|
"id": &memdb.IndexSchema{
|
||||||
|
Name: "id",
|
||||||
AllowMissing: false,
|
AllowMissing: false,
|
||||||
Unique: true,
|
Unique: true,
|
||||||
Indexer: &memdb.StringFieldIndex{
|
Indexer: &memdb.StringFieldIndex{
|
||||||
|
@ -220,6 +230,7 @@ func sessionsTableSchema() *memdb.TableSchema {
|
||||||
Name: "sessions",
|
Name: "sessions",
|
||||||
Indexes: map[string]*memdb.IndexSchema{
|
Indexes: map[string]*memdb.IndexSchema{
|
||||||
"id": &memdb.IndexSchema{
|
"id": &memdb.IndexSchema{
|
||||||
|
Name: "id",
|
||||||
AllowMissing: false,
|
AllowMissing: false,
|
||||||
Unique: true,
|
Unique: true,
|
||||||
Indexer: &memdb.StringFieldIndex{
|
Indexer: &memdb.StringFieldIndex{
|
||||||
|
@ -228,6 +239,7 @@ func sessionsTableSchema() *memdb.TableSchema {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"node": &memdb.IndexSchema{
|
"node": &memdb.IndexSchema{
|
||||||
|
Name: "node",
|
||||||
AllowMissing: true,
|
AllowMissing: true,
|
||||||
Unique: false,
|
Unique: false,
|
||||||
Indexer: &memdb.StringFieldIndex{
|
Indexer: &memdb.StringFieldIndex{
|
||||||
|
@ -246,6 +258,7 @@ func sessionChecksTableSchema() *memdb.TableSchema {
|
||||||
Name: "session_checks",
|
Name: "session_checks",
|
||||||
Indexes: map[string]*memdb.IndexSchema{
|
Indexes: map[string]*memdb.IndexSchema{
|
||||||
"id": &memdb.IndexSchema{
|
"id": &memdb.IndexSchema{
|
||||||
|
Name: "id",
|
||||||
AllowMissing: false,
|
AllowMissing: false,
|
||||||
Unique: true,
|
Unique: true,
|
||||||
Indexer: &memdb.CompoundIndex{
|
Indexer: &memdb.CompoundIndex{
|
||||||
|
@ -276,6 +289,7 @@ func aclsTableSchema() *memdb.TableSchema {
|
||||||
Name: "acls",
|
Name: "acls",
|
||||||
Indexes: map[string]*memdb.IndexSchema{
|
Indexes: map[string]*memdb.IndexSchema{
|
||||||
"id": &memdb.IndexSchema{
|
"id": &memdb.IndexSchema{
|
||||||
|
Name: "id",
|
||||||
AllowMissing: false,
|
AllowMissing: false,
|
||||||
Unique: true,
|
Unique: true,
|
||||||
Indexer: &memdb.StringFieldIndex{
|
Indexer: &memdb.StringFieldIndex{
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
package state
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/hashicorp/go-memdb"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestStateStore_Schema(t *testing.T) {
|
||||||
|
// First call the schema creation
|
||||||
|
schema := stateStoreSchema()
|
||||||
|
|
||||||
|
// Try to initialize a new memdb using the schema
|
||||||
|
if _, err := memdb.NewMemDB(schema); err != nil {
|
||||||
|
t.Fatalf("err: %s", err)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue