github.com/muhammadn/cortex@v1.9.1-0.20220510110439-46bb7000d03d/pkg/util/validation/exporter_test.go (about) 1 package validation 2 3 import ( 4 "testing" 5 6 "github.com/prometheus/client_golang/prometheus/testutil" 7 "github.com/stretchr/testify/assert" 8 ) 9 10 func TestOverridesExporter_noConfig(t *testing.T) { 11 exporter := NewOverridesExporter(newMockTenantLimits(nil)) 12 13 // With no updated override configurations, there should be no override metrics 14 count := testutil.CollectAndCount(exporter, "cortex_overrides") 15 assert.Equal(t, 0, count) 16 } 17 18 func TestOverridesExporter_withConfig(t *testing.T) { 19 tenantLimits := map[string]*Limits{ 20 "tenant-a": { 21 MaxQueriersPerTenant: 5, 22 }, 23 } 24 25 exporter := NewOverridesExporter(newMockTenantLimits(tenantLimits)) 26 27 // There should be at least a few metrics generated by receiving an override configuration map 28 count := testutil.CollectAndCount(exporter, "cortex_overrides") 29 assert.Greater(t, count, 0) 30 }