From 69ce10602f11c88a3c8fb6d3ac0646e9462317b8 Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Wed, 10 Mar 2021 14:18:41 -0500 Subject: [PATCH] state: add tests for config-entry indexers --- agent/consul/state/config_entry_oss_test.go | 35 +++++++++++++++++++++ agent/consul/state/schema_test.go | 7 +++-- 2 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 agent/consul/state/config_entry_oss_test.go diff --git a/agent/consul/state/config_entry_oss_test.go b/agent/consul/state/config_entry_oss_test.go new file mode 100644 index 0000000000..62245d70c4 --- /dev/null +++ b/agent/consul/state/config_entry_oss_test.go @@ -0,0 +1,35 @@ +// +build !consulent + +package state + +import "github.com/hashicorp/consul/agent/structs" + +func testIndexerTableConfigEntries() map[string]indexerTestCase { + return map[string]indexerTestCase{ + indexID: { + read: indexValue{ + source: ConfigEntryKindName{ + Kind: "Proxy-Defaults", + Name: "NaMe", + }, + expected: []byte("proxy-defaults\x00name\x00"), + }, + write: indexValue{ + source: &structs.ProxyConfigEntry{Name: "NaMe"}, + expected: []byte("proxy-defaults\x00name\x00"), + }, + }, + indexKind: { + read: indexValue{ + source: ConfigEntryKindQuery{ + Kind: "Service-Defaults", + }, + expected: []byte("service-defaults\x00"), + }, + write: indexValue{ + source: &structs.ServiceConfigEntry{}, + expected: []byte("service-defaults\x00"), + }, + }, + } +} diff --git a/agent/consul/state/schema_test.go b/agent/consul/state/schema_test.go index 5d05cea7f5..52738051e5 100644 --- a/agent/consul/state/schema_test.go +++ b/agent/consul/state/schema_test.go @@ -128,9 +128,10 @@ func TestNewDBSchema_Indexers(t *testing.T) { require.NoError(t, schema.Validate()) var testcases = map[string]func() map[string]indexerTestCase{ - tableChecks: testIndexerTableChecks, - tableServices: testIndexerTableServices, - tableNodes: testIndexerTableNodes, + tableChecks: testIndexerTableChecks, + tableServices: testIndexerTableServices, + tableNodes: testIndexerTableNodes, + tableConfigEntries: testIndexerTableConfigEntries, } for _, table := range schema.Tables {