omni/internal/backend/runtime/runtime_test.go
Artem Chernyshev ed946b30a6
feat: display OMNI_ENDPOINT in the service account creation UI
Fixes: https://github.com/siderolabs/omni/issues/858

Signed-off-by: Artem Chernyshev <artem.chernyshev@talos-systems.com>
2025-01-29 15:27:36 +03:00

47 lines
1.3 KiB
Go

// Copyright (c) 2025 Sidero Labs, Inc.
//
// Use of this software is governed by the Business Source License
// included in the LICENSE file.
package runtime_test
import (
"context"
"fmt"
"testing"
"github.com/stretchr/testify/require"
"github.com/siderolabs/omni/internal/backend/runtime"
"github.com/siderolabs/omni/internal/backend/runtime/kubernetes"
)
//nolint:iface
func TestInstall_LookupInterface(t *testing.T) {
k8s, err := kubernetes.New(nil)
require.NoError(t, err)
runtime.Install(kubernetes.Name, k8s)
type incorrectIface interface {
GetClient(ctx context.Context, cluster string) (kubernetes.Client, error)
}
_, err = runtime.LookupInterface[incorrectIface](kubernetes.Name)
require.EqualError(t, err, fmt.Sprintf("runtime with id %s is not incorrectIface", kubernetes.Name))
type incorrectUnnamedIface = interface {
GetClient(ctx context.Context, cluster string) (kubernetes.Client, error)
}
_, err = runtime.LookupInterface[incorrectUnnamedIface](kubernetes.Name)
require.EqualError(t, err, fmt.Sprintf("runtime with id %s is not interface { GetClient(context.Context, string) (kubernetes.Client, error) }", kubernetes.Name))
type correctIface = interface {
GetClient(ctx context.Context, cluster string) (*kubernetes.Client, error)
}
_, err = runtime.LookupInterface[correctIface](kubernetes.Name)
require.NoError(t, err)
}