(t *testing.T)
| 162 | } |
| 163 | |
| 164 | func TestGaugeFunc(t *testing.T) { |
| 165 | gf := NewGaugeFunc( |
| 166 | GaugeOpts{ |
| 167 | Name: "test_name", |
| 168 | Help: "test help", |
| 169 | ConstLabels: Labels{"a": "1", "b": "2"}, |
| 170 | }, |
| 171 | func() float64 { return 3.1415 }, |
| 172 | ) |
| 173 | |
| 174 | if expected, got := `Desc{fqName: "test_name", help: "test help", constLabels: {a="1",b="2"}, variableLabels: {}}`, gf.Desc().String(); expected != got { |
| 175 | t.Errorf("expected %q, got %q", expected, got) |
| 176 | } |
| 177 | |
| 178 | m := &dto.Metric{} |
| 179 | gf.Write(m) |
| 180 | |
| 181 | expected := &dto.Metric{ |
| 182 | Label: []*dto.LabelPair{ |
| 183 | {Name: proto.String("a"), Value: proto.String("1")}, |
| 184 | {Name: proto.String("b"), Value: proto.String("2")}, |
| 185 | }, |
| 186 | Gauge: &dto.Gauge{ |
| 187 | Value: proto.Float64(3.1415), |
| 188 | }, |
| 189 | } |
| 190 | |
| 191 | if !proto.Equal(expected, m) { |
| 192 | t.Errorf("expected %q, got %q", expected, m) |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | func TestGaugeSetCurrentTime(t *testing.T) { |
| 197 | g := NewGauge(GaugeOpts{ |
nothing calls this directly
no test coverage detected