mirror of
https://github.com/siderolabs/omni.git
synced 2025-08-09 02:56:59 +02:00
Omni is source-available under BUSL. Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com> Co-Authored-By: Artem Chernyshev <artem.chernyshev@talos-systems.com> Co-Authored-By: Utku Ozdemir <utku.ozdemir@siderolabs.com> Co-Authored-By: Dmitriy Matrenichev <dmitry.matrenichev@siderolabs.com> Co-Authored-By: Philipp Sauter <philipp.sauter@siderolabs.com> Co-Authored-By: Noel Georgi <git@frezbo.dev> Co-Authored-By: evgeniybryzh <evgeniybryzh@gmail.com> Co-Authored-By: Tim Jones <tim.jones@siderolabs.com> Co-Authored-By: Andrew Rynhard <andrew@rynhard.io> Co-Authored-By: Spencer Smith <spencer.smith@talos-systems.com> Co-Authored-By: Christian Rolland <christian.rolland@siderolabs.com> Co-Authored-By: Gerard de Leeuw <gdeleeuw@leeuwit.nl> Co-Authored-By: Steve Francis <67986293+steverfrancis@users.noreply.github.com> Co-Authored-By: Volodymyr Mazurets <volodymyrmazureets@gmail.com>
46 lines
1.3 KiB
Go
46 lines
1.3 KiB
Go
// Copyright (c) 2024 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"
|
|
)
|
|
|
|
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)
|
|
}
|