(t *testing.T)
| 933 | } |
| 934 | |
| 935 | func TestLimitsPerLabelSetsForSeries(t *testing.T) { |
| 936 | for _, tc := range []struct { |
| 937 | name string |
| 938 | limits []LimitsPerLabelSet |
| 939 | metric labels.Labels |
| 940 | expectedLimits []LimitsPerLabelSet |
| 941 | }{ |
| 942 | { |
| 943 | name: "no limits", |
| 944 | metric: labels.FromMap(map[string]string{"foo": "bar"}), |
| 945 | }, |
| 946 | { |
| 947 | name: "no limits matched", |
| 948 | metric: labels.FromMap(map[string]string{"foo": "bar"}), |
| 949 | limits: []LimitsPerLabelSet{ |
| 950 | {LabelSet: labels.FromMap(map[string]string{"foo": "baz"})}, |
| 951 | }, |
| 952 | expectedLimits: []LimitsPerLabelSet{}, |
| 953 | }, |
| 954 | { |
| 955 | name: "one limit matched", |
| 956 | metric: labels.FromMap(map[string]string{"foo": "bar"}), |
| 957 | limits: []LimitsPerLabelSet{ |
| 958 | {LabelSet: labels.FromMap(map[string]string{"foo": "baz"})}, |
| 959 | {LabelSet: labels.FromMap(map[string]string{"foo": "bar"})}, |
| 960 | }, |
| 961 | expectedLimits: []LimitsPerLabelSet{ |
| 962 | {LabelSet: labels.FromMap(map[string]string{"foo": "bar"})}, |
| 963 | }, |
| 964 | }, |
| 965 | { |
| 966 | name: "default limit matched", |
| 967 | metric: labels.FromMap(map[string]string{"foo": "bar"}), |
| 968 | limits: []LimitsPerLabelSet{ |
| 969 | {LabelSet: labels.FromMap(map[string]string{"foo": "baz"})}, |
| 970 | {LabelSet: labels.FromMap(map[string]string{})}, |
| 971 | }, |
| 972 | expectedLimits: []LimitsPerLabelSet{ |
| 973 | {LabelSet: labels.FromMap(map[string]string{})}, |
| 974 | }, |
| 975 | }, |
| 976 | { |
| 977 | name: "one limit matched so not picking default limit", |
| 978 | metric: labels.FromMap(map[string]string{"foo": "bar", "cluster": "us-west-2"}), |
| 979 | limits: []LimitsPerLabelSet{ |
| 980 | {LabelSet: labels.FromMap(map[string]string{"foo": "bar", "cluster": "us-west-2"})}, |
| 981 | {LabelSet: labels.FromMap(map[string]string{})}, |
| 982 | }, |
| 983 | expectedLimits: []LimitsPerLabelSet{ |
| 984 | {LabelSet: labels.FromMap(map[string]string{"foo": "bar", "cluster": "us-west-2"})}, |
| 985 | }, |
| 986 | }, |
| 987 | } { |
| 988 | t.Run(tc.name, func(t *testing.T) { |
| 989 | matched := LimitsPerLabelSetsForSeries(tc.limits, tc.metric) |
| 990 | require.Equal(t, tc.expectedLimits, matched) |
| 991 | }) |
| 992 | } |
nothing calls this directly
no test coverage detected