MCPcopy Index your code
hub / github.com/tailscale/tailscale / TestNetmapDisplayMessage

Function TestNetmapDisplayMessage

control/controlclient/map_test.go:1616–1792  ·  view source on GitHub ↗

TestNetmapDisplayMessage checks that the various diff operations (add/update/delete/clear) for [tailcfg.DisplayMessage] in a [tailcfg.MapResponse] work as expected.

(t *testing.T)

Source from the content-addressed store, hash-verified

1614// (add/update/delete/clear) for [tailcfg.DisplayMessage] in a
1615// [tailcfg.MapResponse] work as expected.
1616func TestNetmapDisplayMessage(t *testing.T) {
1617 type test struct {
1618 name string
1619 initialState *tailcfg.MapResponse
1620 mapResponse tailcfg.MapResponse
1621 wantMessages map[tailcfg.DisplayMessageID]tailcfg.DisplayMessage
1622 }
1623
1624 tests := []test{
1625 {
1626 name: "basic-set",
1627 mapResponse: tailcfg.MapResponse{
1628 DisplayMessages: map[tailcfg.DisplayMessageID]*tailcfg.DisplayMessage{
1629 "test-message": {
1630 Title: "Testing",
1631 Text: "This is a test message",
1632 Severity: tailcfg.SeverityHigh,
1633 ImpactsConnectivity: true,
1634 PrimaryAction: &tailcfg.DisplayMessageAction{
1635 URL: "https://www.example.com",
1636 Label: "Learn more",
1637 },
1638 },
1639 },
1640 },
1641 wantMessages: map[tailcfg.DisplayMessageID]tailcfg.DisplayMessage{
1642 "test-message": {
1643 Title: "Testing",
1644 Text: "This is a test message",
1645 Severity: tailcfg.SeverityHigh,
1646 ImpactsConnectivity: true,
1647 PrimaryAction: &tailcfg.DisplayMessageAction{
1648 URL: "https://www.example.com",
1649 Label: "Learn more",
1650 },
1651 },
1652 },
1653 },
1654 {
1655 name: "delete-one",
1656 initialState: &tailcfg.MapResponse{
1657 DisplayMessages: map[tailcfg.DisplayMessageID]*tailcfg.DisplayMessage{
1658 "message-a": {
1659 Title: "Message A",
1660 },
1661 "message-b": {
1662 Title: "Message B",
1663 },
1664 },
1665 },
1666 mapResponse: tailcfg.MapResponse{
1667 DisplayMessages: map[tailcfg.DisplayMessageID]*tailcfg.DisplayMessage{
1668 "message-a": nil,
1669 },
1670 },
1671 wantMessages: map[tailcfg.DisplayMessageID]tailcfg.DisplayMessage{
1672 "message-b": {
1673 Title: "Message B",

Callers

nothing calls this directly

Calls 5

newTestMapSessionFunction · 0.85
netmapForResponseMethod · 0.80
DiffMethod · 0.80
RunMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…