(t *testing.T)
| 254 | } |
| 255 | |
| 256 | func TestLimitsLoadingFromJson(t *testing.T) { |
| 257 | SetDefaultLimitsForYAMLUnmarshalling(Limits{ |
| 258 | MaxLabelNameLength: 100, |
| 259 | }) |
| 260 | |
| 261 | inp := `{"ingestion_rate": 0.5}` |
| 262 | |
| 263 | l := Limits{} |
| 264 | err := json.Unmarshal([]byte(inp), &l) |
| 265 | require.NoError(t, err) |
| 266 | |
| 267 | assert.Equal(t, 0.5, l.IngestionRate, "from json") |
| 268 | assert.Equal(t, 100, l.MaxLabelNameLength, "from defaults") |
| 269 | |
| 270 | // Unmarshal should fail if input contains unknown struct fields and |
| 271 | // the decoder flag `json.Decoder.DisallowUnknownFields()` is set |
| 272 | inp = `{"unknown_fields": 100}` |
| 273 | l = Limits{} |
| 274 | dec := json.NewDecoder(strings.NewReader(inp)) |
| 275 | dec.DisallowUnknownFields() |
| 276 | err = dec.Decode(&l) |
| 277 | assert.Error(t, err) |
| 278 | } |
| 279 | |
| 280 | func TestLimitsTagsYamlMatchJson(t *testing.T) { |
| 281 | limits := reflect.TypeFor[Limits]() |
nothing calls this directly
no test coverage detected