|
| 1 | +// Copyright 2025 Authors of spidernet-io |
| 2 | +// SPDX-License-Identifier: Apache-2.0 |
| 3 | +package podmanager_test |
| 4 | + |
| 5 | +// import ( |
| 6 | +// "context" |
| 7 | +// "testing" |
| 8 | + |
| 9 | +// . "github.com/onsi/ginkgo/v2" |
| 10 | +// . "github.com/onsi/gomega" |
| 11 | +// "github.com/spidernet-io/spiderpool/pkg/podmanager" |
| 12 | +// corev1 "k8s.io/api/core/v1" |
| 13 | +// metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 14 | +// "k8s.io/client-go/rest" |
| 15 | +// "sigs.k8s.io/controller-runtime/pkg/client" |
| 16 | +// "sigs.k8s.io/controller-runtime/pkg/manager" |
| 17 | +// ) |
| 18 | + |
| 19 | +// func TestPodWebhook(t *testing.T) { |
| 20 | +// RegisterFailHandler(Fail) |
| 21 | +// RunSpecs(t, "Pod Webhook Suite") |
| 22 | +// } |
| 23 | + |
| 24 | +// var _ = Describe("Pod Webhook", Label("pod_webhook_test"), func() { |
| 25 | +// var ( |
| 26 | +// err error |
| 27 | +// mgr manager.Manager |
| 28 | +// ctx context.Context |
| 29 | +// pod *corev1.Pod |
| 30 | +// ) |
| 31 | + |
| 32 | +// BeforeEach(func() { |
| 33 | +// // Create a new manager |
| 34 | + |
| 35 | +// mgr, err = manager.New(cfg, manager.Options{ |
| 36 | +// NewClient: func(config *rest.Config, options client.Options) (client.Client, error) { |
| 37 | +// return nil, nil |
| 38 | +// }, |
| 39 | +// }) |
| 40 | +// Expect(err).NotTo(HaveOccurred()) |
| 41 | + |
| 42 | +// pod = &corev1.Pod{ |
| 43 | +// ObjectMeta: metav1.ObjectMeta{ |
| 44 | +// Namespace: "default", |
| 45 | +// GenerateName: "test-pod", |
| 46 | +// Annotations: map[string]string{}, |
| 47 | +// }, |
| 48 | +// } |
| 49 | +// }) |
| 50 | + |
| 51 | +// Context("InitPodWebhook", func() { |
| 52 | +// It("should initialize without error", func() { |
| 53 | +// err := podmanager.InitPodWebhook(mgr) |
| 54 | +// Expect(err).NotTo(HaveOccurred()) |
| 55 | +// }) |
| 56 | +// }) |
| 57 | + |
| 58 | +// Context("Default", func() { |
| 59 | +// It("should not inject resources if no annotations are present", func() { |
| 60 | +// pw := &podmanager.PWebhook{} |
| 61 | +// err := pw.Default(ctx, pod) |
| 62 | +// Expect(err).NotTo(HaveOccurred()) |
| 63 | +// }) |
| 64 | + |
| 65 | +// It("should inject resources if annotations are present", func() { |
| 66 | +// pod.Annotations["spiderpool.io/pod-resource-inject"] = "true" |
| 67 | +// pw := podmanager.PWebhook{} |
| 68 | +// err := pw.Default(ctx, pod) |
| 69 | +// Expect(err).NotTo(HaveOccurred()) |
| 70 | +// }) |
| 71 | +// }) |
| 72 | +// }) |
0 commit comments