Help us shape the future of Go! Take the 2026 Go Developer Survey

testtemplate

package
v1.70.2 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: MPL-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActionTemplateDir added in v1.61.0

func ActionTemplateDir(t *testing.T) string

ActionTemplateDir returns the path to the directory where the templates for individual actions are kept.

Inside the action template directory exists a template file with a name of the format <action_name>.tf.tmpl for each action provided by the Hetzner Cloud Terraform provider.

The individual templates must define a valid HCL snippet for the action. They must not reference other resources or data sources, and they must not import other templates.

func DataSourceTemplateDir

func DataSourceTemplateDir(t *testing.T) string

DataSourceTemplateDir returns the path to the directory where the templates for individual data sources are kept.

Inside the data source template directory exists a template file with a name of the format <data_source_name>.tf.tmpl for each data source provided by the Hetzner Cloud Terraform provider.

The individual templates must define a valid HCL snippet for the data source. They must not reference other resources or data sources and they must not import other templates.

func DeepCopy added in v1.57.0

func DeepCopy[T Data](t *testing.T, value T) T

DeepCopy copies the content of a template resource, and preserves the resource name and id.

func ResourceTemplateDir

func ResourceTemplateDir(t *testing.T) string

ResourceTemplateDir returns the path to the directory where the templates for individual resources are kept.

Inside the resource template directory exists a template file with a name of the format <resource_name>.tf.tmpl for each resource provided by the Hetzner Cloud Terraform provider.

The individual templates must define a valid HCL snippet for the resource. They must not reference other resources or data sources and they must not import other templates.

Types

type Data

type Data interface {
	SetRInt(int)
	SetRName(string)
	RInt() int
	RName() string
}

Data marks a struct as containing data for test templates.

type DataCommon

type DataCommon struct {
	// contains filtered or unexported fields
}

DataCommon contains fields required by all template data types.

func (*DataCommon) RInt

func (tdc *DataCommon) RInt() int

RInt returns the random integer

func (*DataCommon) RName

func (tdc *DataCommon) RName() string

RInt returns the random name

func (*DataCommon) SetRInt

func (tdc *DataCommon) SetRInt(i int)

SetRInt sets a random integer.

func (*DataCommon) SetRName

func (tdc *DataCommon) SetRName(n string)

SetRName sets a resource name.

type Manager

type Manager struct {
	RandInt  int
	RandName string
	// contains filtered or unexported fields
}

Manager loads and renders Terraform HCL templates.

func (*Manager) Render

func (ts *Manager) Render(t *testing.T, args ...any) string

Render renders the passed template to a string using the provided data.

Jump to

Keyboard shortcuts

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