Files
teleport/lib/cache/installer_test.go
Luke Okraszewski b1cb774ea0 [api] Add ListInstallers (#60499)
This commits deperecates GetInstallers, which should be replaced by a paginated counterpart: ListInstallers

A new stream helper `MergeStreamsWithPriority` is added which can be used to resolve
clashing compare keys in two streams.

Towards: gravitational/teleport.e/issues/6759
Changelog: Add paginated API ListInstallers, deprecate GetInstallers
2025-10-24 14:22:39 +00:00

61 lines
1.9 KiB
Go

// Teleport
// Copyright (C) 2025 Gravitational, Inc.
//
// 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 <http://www.gnu.org/licenses/>.
package cache
import (
"context"
"testing"
"github.com/gravitational/teleport/api/types"
)
func TestInstallers(t *testing.T) {
t.Parallel()
p := newTestPack(t, ForAuth)
t.Cleanup(p.Close)
t.Run("GetInstallers", func(t *testing.T) {
testResources(t, p, testFuncs[types.Installer]{
newResource: func(name string) (types.Installer, error) {
return types.NewInstallerV1(name, "test.sh")
},
create: p.clusterConfigS.SetInstaller,
list: getAllAdapter(p.clusterConfigS.GetInstallers),
cacheList: getAllAdapter(p.cache.GetInstallers),
deleteAll: func(ctx context.Context) error {
return p.clusterConfigS.DeleteAllInstallers(ctx)
},
}, withSkipPaginationTest())
})
t.Run("ListInstallers", func(t *testing.T) {
testResources(t, p, testFuncs[types.Installer]{
newResource: func(name string) (types.Installer, error) {
return types.NewInstallerV1(name, "test.sh")
},
create: p.clusterConfigS.SetInstaller,
list: p.clusterConfigS.ListInstallers,
Range: p.clusterConfigS.RangeInstallers,
cacheList: p.cache.ListInstallers,
cacheRange: p.cache.RangeInstallers,
deleteAll: func(ctx context.Context) error {
return p.clusterConfigS.DeleteAllInstallers(ctx)
},
})
})
}