Skip to content

Commit

Permalink
PMM-13078 add an api test
Browse files Browse the repository at this point in the history
  • Loading branch information
ademidoff committed Jul 18, 2024
1 parent 9163441 commit 2837e0f
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions api-tests/management/services/agent_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright (C) 2023 Percona LLC
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

package services

import (
"context"
"testing"
"time"

"github.com/AlekSi/pointer"
"github.com/stretchr/testify/require"

pmmapitests "github.com/percona/pmm/api-tests"
"github.com/percona/pmm/api/management/v1/json/client"
mgmtSvc "github.com/percona/pmm/api/management/v1/json/client/management_service"
)

func TestListAgentVersions(t *testing.T) {
ctx, cancel := context.WithTimeout(pmmapitests.Context, 30*time.Second)
t.Cleanup(func() { cancel() })

t.Run("PMM Agent needs no update", func(t *testing.T) {
listAgentVersionsOK, err := client.Default.ManagementService.ListAgentVersions(
&mgmtSvc.ListAgentVersionsParams{
Context: ctx,
})
require.NoError(t, err)
require.Len(t, listAgentVersionsOK.Payload.Versions, 1)

expected := pointer.ToString(mgmtSvc.ListAgentVersionsOKBodyVersionsItems0SeverityUPDATESEVERITYUPTODATE)
require.Equal(t, expected, listAgentVersionsOK.Payload.Versions[0].Severity)
})
}

0 comments on commit 2837e0f

Please sign in to comment.