open-consul/agent/consul/usagemetrics/usagemetrics_test.go
Ronald dd0e8eec14
copyright headers for agent folder (#16704)
* copyright headers for agent folder

* Ignore test data files

* fix proto files and remove headers in agent/uiserver folder

* ignore deep-copy files
2023-03-28 14:39:22 -04:00

42 lines
906 B
Go

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package usagemetrics
import (
"testing"
"github.com/armon/go-metrics"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/hashicorp/consul/agent/consul/state"
)
type mockStateProvider struct {
mock.Mock
}
func (m *mockStateProvider) State() *state.Store {
retValues := m.Called()
return retValues.Get(0).(*state.Store)
}
func assertEqualGaugeMaps(t *testing.T, expectedMap, foundMap map[string]metrics.GaugeValue) {
t.Helper()
for key := range foundMap {
if _, ok := expectedMap[key]; !ok {
t.Errorf("found unexpected gauge key: %s", key)
}
}
for key, expected := range expectedMap {
if _, ok := foundMap[key]; !ok {
t.Errorf("did not find expected gauge key: %s", key)
continue
}
assert.Equal(t, expected, foundMap[key], "gauge key mismatch on %q", key)
}
}