(t *testing.T)
| 754 | } |
| 755 | |
| 756 | func TestAlreadyRegistered(t *testing.T) { |
| 757 | original := prometheus.NewCounterVec( |
| 758 | prometheus.CounterOpts{ |
| 759 | Name: "test", |
| 760 | Help: "help", |
| 761 | ConstLabels: prometheus.Labels{"const": "label"}, |
| 762 | }, |
| 763 | []string{"foo", "bar"}, |
| 764 | ) |
| 765 | equalButNotSame := prometheus.NewCounterVec( |
| 766 | prometheus.CounterOpts{ |
| 767 | Name: "test", |
| 768 | Help: "help", |
| 769 | ConstLabels: prometheus.Labels{"const": "label"}, |
| 770 | }, |
| 771 | []string{"foo", "bar"}, |
| 772 | ) |
| 773 | originalWithoutConstLabel := prometheus.NewCounterVec( |
| 774 | prometheus.CounterOpts{ |
| 775 | Name: "test", |
| 776 | Help: "help", |
| 777 | }, |
| 778 | []string{"foo", "bar"}, |
| 779 | ) |
| 780 | equalButNotSameWithoutConstLabel := prometheus.NewCounterVec( |
| 781 | prometheus.CounterOpts{ |
| 782 | Name: "test", |
| 783 | Help: "help", |
| 784 | }, |
| 785 | []string{"foo", "bar"}, |
| 786 | ) |
| 787 | |
| 788 | scenarios := []struct { |
| 789 | name string |
| 790 | originalCollector prometheus.Collector |
| 791 | registerWith func(prometheus.Registerer) prometheus.Registerer |
| 792 | newCollector prometheus.Collector |
| 793 | reRegisterWith func(prometheus.Registerer) prometheus.Registerer |
| 794 | }{ |
| 795 | { |
| 796 | "RegisterNormallyReregisterNormally", |
| 797 | original, |
| 798 | func(r prometheus.Registerer) prometheus.Registerer { return r }, |
| 799 | equalButNotSame, |
| 800 | func(r prometheus.Registerer) prometheus.Registerer { return r }, |
| 801 | }, |
| 802 | { |
| 803 | "RegisterNormallyReregisterWrapped", |
| 804 | original, |
| 805 | func(r prometheus.Registerer) prometheus.Registerer { return r }, |
| 806 | equalButNotSameWithoutConstLabel, |
| 807 | func(r prometheus.Registerer) prometheus.Registerer { |
| 808 | return prometheus.WrapRegistererWith(prometheus.Labels{"const": "label"}, r) |
| 809 | }, |
| 810 | }, |
| 811 | { |
| 812 | "RegisterWrappedReregisterWrapped", |
| 813 | originalWithoutConstLabel, |
nothing calls this directly
no test coverage detected