testhelpers

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2025 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package testhelpers provides shared testing utilities used across unit and acceptance tests.

Intended use:

  • Unit tests: builders, fixtures, and assertions to reduce boilerplate.
  • Acceptance tests: environment pre-checks, deterministic name generators, retry/backoff test stubs, and helpers for external service setup/teardown.
  • HTTP/logging tests: redaction utilities, fake clients/round-trippers, and golden-file helpers with stable, sorted outputs.

Conventions:

  • Keep dependencies minimal and avoid importing production-only paths.
  • Ensure deterministic outputs: sort collections, use stable IDs, and normalize values before comparisons or serialization.
  • Never leak secrets in logs, errors, or golden files; always redact.

This package is for test code and is not part of the provider's public API.

Index

Constants

View Source
const (
	TmplPath          = "./testdata/templates"
	DataWorkTypesTmpl = "data.work_types.tf.tmpl"
	WorkTypeTmpl      = "work_type.tf.tmpl"
	DataProjectTmpl   = "data.projects.tf.tmpl"
	ProjectTmpl       = "project.tf.tmpl"
	ProjectCatTmpl    = "project_category.tf.tmpl"
)
View Source
const (
	HierarchyStandard = 0
	HierarchySubtask  = -1
)

Common hierarchy levels used across tests.

Variables

View Source
var (
	DataWorkTypesTmplPath = filepath.Join(TmplPath, DataWorkTypesTmpl)
	WorkTypeTmplPath      = filepath.Join(TmplPath, WorkTypeTmpl)

	DataProjectTmplPath = filepath.Join(TmplPath, DataProjectTmpl)
	ProjectTmplPath     = filepath.Join(TmplPath, ProjectTmpl)

	ProjectCatTmplPath = filepath.Join(TmplPath, ProjectCatTmpl)

	StandardWorkType = 0
	SubtaskWorkType  = -1
)

Functions

func BuildLargeBody

func BuildLargeBody() string

BuildLargeBody creates a large JSON-like string embedding various secrets to validate both truncation and redaction. Size target ~2MB.

func MkRS

func MkRS(code int, headers http.Header, body string) *models.ResponseScheme

MkRS helper to build a models.ResponseScheme with convenience fields

func MkRSWithBodyAndHeaders

func MkRSWithBodyAndHeaders(code int, hdr http.Header, body string) *models.ResponseScheme

func MustCopy

func MustCopy(t *testing.T, name string, r io.Reader) string

MustCopy copies from r to a temp file and returns its path.

func MustReadTemplate

func MustReadTemplate(t *testing.T, name string) string

MustReadTemplate reads a template by name or fails the test.

func TemplatePath

func TemplatePath(name string) string

TemplatePath returns an absolute path to a template file under testdata/templates.

func TestAccLeadAccountID added in v0.6.0

func TestAccLeadAccountID() string

func TestAccProjectCategoryConfig added in v0.7.0

func TestAccProjectCategoryConfig(t *testing.T, name, desc string) string

func TestAccProjectResourceConfig added in v0.6.0

func TestAccProjectResourceConfig(t *testing.T, key, name, projectType, leadAccountID, description string) string

func TestAccProjectWithDataSource added in v0.6.0

func TestAccProjectWithDataSource(t *testing.T, key, name, projectType, lookupType string) string

TestAccProjectWithDataSource generates a Terraform configuration string for creating a Jira project and data sources. This function requires project attributes such as key, name, project type, and lookup type. It uses a template file to build the configuration and executes it with provided parameters. The returned string can be used in acceptance tests to verify resource and data source integration.

Types

type DataProjectsCfg added in v0.6.0

type DataProjectsCfg struct {
	ProjectResources []string
	DataName         string
	LookupBy         string
}

type FakeNetErr

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

FakeNetErr for testing ShouldRetry timeout path

func NewFakeNetErr

func NewFakeNetErr(timeout bool) FakeNetErr

NewFakeNetErr constructs a FakeNetErr with the provided timeout flag.

func (FakeNetErr) Error

func (e FakeNetErr) Error() string

func (FakeNetErr) Temporary

func (e FakeNetErr) Temporary() bool

func (FakeNetErr) Timeout

func (e FakeNetErr) Timeout() bool

type FakeTypeService

FakeTypeService provides a minimal test double for jira.TypeConnector used in unit tests. It exposes function fields so tests can customize behavior per case.

func (*FakeTypeService) Create

func (*FakeTypeService) Delete

func (*FakeTypeService) Get

func (*FakeTypeService) Update

type ProjectCatTmplCfg added in v0.7.0

type ProjectCatTmplCfg struct {
	Name        string
	Description string
}

type ProjectTmplCfg added in v0.6.0

type ProjectTmplCfg struct {
	Key           string
	Name          string
	ProjectType   string
	LeadAccountID string
	Description   string
}

Jump to

Keyboard shortcuts

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