test

package
v1.12.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 13, 2026 License: BSD-2-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalAsYaml

func MarshalAsYaml(input interface{}) []byte

MarshalAsYaml is a test utility function that marshals Kubernetes objects to YAML format. It automatically fails the test if marshaling fails.

Usage example:

import (

"strings"
libk8stest "github.com/bborbe/k8s/test"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gbytes"

)

It("has correct YAML content", func() {
	// Marshal any Kubernetes object to YAML
	bytes := libk8stest.MarshalAsYaml(service)

	// Verify the YAML contains expected content
	Expect(gbytes.BufferWithBytes(bytes)).To(gbytes.Say(strings.TrimSpace(`

apiVersion: v1 kind: Service metadata:

name: my-service
namespace: default

spec:

ports:
- port: 80
  targetPort: 8080
selector:
  app: my-app

`))) })

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL