A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/grafana/mcp-grafana/commit/85588918e8f586cdcf7289c5c44abe4fa73a1a97 below:

Add listing all contact points with limits (#81) · grafana/mcp-grafana@8558891 · GitHub

@@ -399,3 +399,85 @@ func TestAlertingTools_GetAlertRuleByUID(t *testing.T) {

399 399

require.Contains(t, err.Error(), "getAlertRuleNotFound")

400 400

})

401 401

}

402 + 403 +

var (

404 +

emailType = "email"

405 + 406 +

contactPoint1 = contactPointSummary{

407 +

UID: "email1",

408 +

Name: "Email1",

409 +

Type: &emailType,

410 +

}

411 +

contactPoint2 = contactPointSummary{

412 +

UID: "email2",

413 +

Name: "Email2",

414 +

Type: &emailType,

415 +

}

416 +

contactPoint3 = contactPointSummary{

417 +

UID: "",

418 +

Name: "email receiver",

419 +

Type: &emailType,

420 +

}

421 +

allExpectedContactPoints = []contactPointSummary{contactPoint1, contactPoint2, contactPoint3}

422 +

)

423 + 424 +

func TestAlertingTools_ListContactPoints(t *testing.T) {

425 +

t.Run("list contact points", func(t *testing.T) {

426 +

ctx := newTestContext()

427 +

result, err := listContactPoints(ctx, ListContactPointsParams{})

428 +

require.NoError(t, err)

429 +

require.ElementsMatch(t, allExpectedContactPoints, result)

430 +

})

431 + 432 +

t.Run("list one contact point", func(t *testing.T) {

433 +

ctx := newTestContext()

434 + 435 +

// Get the contact points with limit 1

436 +

result1, err := listContactPoints(ctx, ListContactPointsParams{

437 +

Limit: 1,

438 +

})

439 +

require.NoError(t, err)

440 +

require.Len(t, result1, 1)

441 +

})

442 + 443 +

t.Run("list contact points with name filter", func(t *testing.T) {

444 +

ctx := newTestContext()

445 +

name := "Email1"

446 + 447 +

result, err := listContactPoints(ctx, ListContactPointsParams{

448 +

Name: &name,

449 +

})

450 +

require.NoError(t, err)

451 +

require.Len(t, result, 1)

452 +

require.Equal(t, "Email1", result[0].Name)

453 +

})

454 + 455 +

t.Run("list contact points with invalid limit parameter", func(t *testing.T) {

456 +

ctx := newTestContext()

457 +

result, err := listContactPoints(ctx, ListContactPointsParams{

458 +

Limit: -1,

459 +

})

460 +

require.Error(t, err)

461 +

require.Empty(t, result)

462 +

})

463 + 464 +

t.Run("list contact points with large limit", func(t *testing.T) {

465 +

ctx := newTestContext()

466 +

result, err := listContactPoints(ctx, ListContactPointsParams{

467 +

Limit: 1000,

468 +

})

469 +

require.NoError(t, err)

470 +

require.NotEmpty(t, result)

471 +

})

472 + 473 +

t.Run("list contact points with non-existent name filter", func(t *testing.T) {

474 +

ctx := newTestContext()

475 +

name := "NonExistentAlert"

476 + 477 +

result, err := listContactPoints(ctx, ListContactPointsParams{

478 +

Name: &name,

479 +

})

480 +

require.NoError(t, err)

481 +

require.Empty(t, result)

482 +

})

483 +

}


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4