testtfc

package
v0.0.0-...-5c2f431 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: MPL-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const ProductIdMetadataHeaderKey = "Tfp-Aws-Service-Catalog-Product-Id"
View Source
const ProductVersionMetadataHeaderKey = "Tfp-Aws-Service-Catalog-Product-Ver"
View Source
const ProvisionedProductIdMetadataHeaderKey = "Tfp-Aws-Service-Catalog-Prv-Product-Id"

Variables

This section is empty.

Functions

func ApplyId

func ApplyId() string

func ConfigVersionId

func ConfigVersionId(workspaceId string) string

func MakeConfigurationVersionResponse

func MakeConfigurationVersionResponse(configVersion *tfe.ConfigurationVersion) map[string]interface{}

func MakeGetRunResponse

func MakeGetRunResponse(run tfe.Run) map[string]interface{}

func MakeGetStateVersionOutputsResponse

func MakeGetStateVersionOutputsResponse(stateVersionOutputs []*tfe.StateVersionOutput, page int, size int) map[string]interface{}

func MakeGetStateVersionResponse

func MakeGetStateVersionResponse(stateVersion tfe.StateVersion) map[string]interface{}

func MakeListProjectsResponse

func MakeListProjectsResponse(projects []*tfe.Project) map[string]interface{}

func MakeListVarsResponse

func MakeListVarsResponse(vars []*tfe.Variable, page int, size int) map[string]interface{}

func MakeListWorkspacesResponse

func MakeListWorkspacesResponse(workspaces []*tfe.Workspace) map[string]interface{}

func MakeProjectResponse

func MakeProjectResponse(project *tfe.Project) map[string]interface{}

func MakeTeamTokenResponse

func MakeTeamTokenResponse(teamToken *tfe.TeamToken) map[string]interface{}

func MakeVarResponse

func MakeVarResponse(variable *tfe.Variable) map[string]interface{}

func MakeWorkspaceResponse

func MakeWorkspaceResponse(workspace *tfe.Workspace) map[string]interface{}

func RunFromRequest

func RunFromRequest(req RunPostRequest) *tfe.Run

func RunId

func RunId(run *tfe.Run) string

func StateVersionId

func StateVersionId(workspaceId string) string

func TruncateString

func TruncateString(str string, length int) string

func VarId

func VarId(variable *tfe.Variable) string

func WorkspaceId

func WorkspaceId(workspace *tfe.Workspace) string

Types

type MockTFC

type MockTFC struct {
	Address string

	OrganizationName string

	// Projects is a map of all the Projects the mock TFC contains, with their respective id as the keys
	Projects map[string]*tfe.Project

	// Workspaces is a map of all the Workspaces the mock TFC contains, with their respective id as the keys
	Workspaces map[string]*tfe.Workspace

	// WorkspaceServiceCatalogMetadata is a map of all the AWS Service Catalog metadata the mock TFC contains, with their respective Workspace IDs as the keys
	WorkspaceServiceCatalogMetadata map[string]*ServiceCatalogMetadata

	// Runs is a map containing the all the Runs the mock TFC contains, the keys are the paths for the Runs
	Runs map[string]*tfe.Run

	// Vars is a map of all the Variables the mock TFC server contains, the keys are the IDs of the Workspaces that own them
	Vars map[string][]*tfe.Variable

	// Applies is a map containing the all the Applies the mock TFC contains, the keys are the paths for the Applies
	Applies map[string]*tfe.Apply

	// StateVersions is a map containing the all the StateVersions the mock TFC contains, the keys are the IDs of the Workspaces that own them
	StateVersions map[string]*tfe.StateVersion

	// StateVersions is a map containing all the StateVersions the mock TFC contains, where the keys are the IDs of the Apply that owns them
	StateVersionsByApply map[string][]*tfe.StateVersion

	// StateVersionOutputs is a map containing the all the StateVersionOutputs the mock TFC contains, the keys are the IDs of the StateVersion that own them
	StateVersionOutputs map[string][]*tfe.StateVersionOutput
	// contains filtered or unexported fields
}

MockTFC handles mocking the agent-related TFC APIs. It exposes methods for creating server-side state, such as jobs in the queue.

func NewMockTFC

func NewMockTFC() *MockTFC

func (*MockTFC) AddApply

func (srv *MockTFC) AddApply(apply *tfe.Apply) *tfe.Apply

func (*MockTFC) AddConfigurationVersion

func (srv *MockTFC) AddConfigurationVersion(workspaceId string, configVersion *tfe.ConfigurationVersion) *tfe.ConfigurationVersion

func (*MockTFC) AddProject

func (srv *MockTFC) AddProject(id string, p ProjectFactoryParameters)

func (*MockTFC) AddRun

func (srv *MockTFC) AddRun(runId string, p RunFactoryParameters) *tfe.Run

func (*MockTFC) AddStateVersion

func (srv *MockTFC) AddStateVersion(applyId string, stateVersion *tfe.StateVersion) *tfe.StateVersion

func (*MockTFC) AddVar

func (srv *MockTFC) AddVar(variable *tfe.Variable) *tfe.Variable

func (*MockTFC) AddWorkspace

func (srv *MockTFC) AddWorkspace(id string, p WorkspaceFactoryParameters) *tfe.Workspace

func (*MockTFC) FailRequests

func (srv *MockTFC) FailRequests(n int32)

FailRequests makes the mock server return a 500 error for the subsequent n requests. This is useful for testing retries.

func (*MockTFC) HandleAppliesGetRequests

func (srv *MockTFC) HandleAppliesGetRequests(w http.ResponseWriter, r *http.Request) bool

func (*MockTFC) HandleConfigurationVersionsGetRequests

func (srv *MockTFC) HandleConfigurationVersionsGetRequests(w http.ResponseWriter, r *http.Request) bool

func (*MockTFC) HandleConfigurationVersionsPostRequests

func (srv *MockTFC) HandleConfigurationVersionsPostRequests(w http.ResponseWriter, r *http.Request) bool

func (*MockTFC) HandleConfigurationVersionsUploads

func (srv *MockTFC) HandleConfigurationVersionsUploads(w http.ResponseWriter, r *http.Request) bool

func (*MockTFC) HandleProjectsGetRequests

func (srv *MockTFC) HandleProjectsGetRequests(w http.ResponseWriter, r *http.Request) bool

func (*MockTFC) HandleProjectsPostRequests

func (srv *MockTFC) HandleProjectsPostRequests(w http.ResponseWriter, r *http.Request) bool

func (*MockTFC) HandleRunsGetRequests

func (srv *MockTFC) HandleRunsGetRequests(w http.ResponseWriter, r *http.Request) bool

func (*MockTFC) HandleRunsPostRequests

func (srv *MockTFC) HandleRunsPostRequests(w http.ResponseWriter, r *http.Request) bool

func (*MockTFC) HandleStateVersionsGetRequests

func (srv *MockTFC) HandleStateVersionsGetRequests(w http.ResponseWriter, r *http.Request) bool

func (*MockTFC) HandleTokensPostRequests

func (srv *MockTFC) HandleTokensPostRequests(w http.ResponseWriter, r *http.Request) bool

func (*MockTFC) HandleVarsDeleteRequests

func (srv *MockTFC) HandleVarsDeleteRequests(w http.ResponseWriter, r *http.Request) bool

func (*MockTFC) HandleVarsGetRequests

func (srv *MockTFC) HandleVarsGetRequests(w http.ResponseWriter, r *http.Request) bool

func (*MockTFC) HandleVarsPatchRequests

func (srv *MockTFC) HandleVarsPatchRequests(w http.ResponseWriter, r *http.Request) bool

func (*MockTFC) HandleVarsPostRequests

func (srv *MockTFC) HandleVarsPostRequests(w http.ResponseWriter, r *http.Request) bool

func (*MockTFC) HandleWorkspacesDeleteRequests

func (srv *MockTFC) HandleWorkspacesDeleteRequests(w http.ResponseWriter, r *http.Request) bool

func (*MockTFC) HandleWorkspacesGetRequests

func (srv *MockTFC) HandleWorkspacesGetRequests(w http.ResponseWriter, r *http.Request) bool

func (*MockTFC) HandleWorkspacesPatchRequests

func (srv *MockTFC) HandleWorkspacesPatchRequests(w http.ResponseWriter, r *http.Request) bool

func (*MockTFC) HandleWorkspacesPostRequests

func (srv *MockTFC) HandleWorkspacesPostRequests(w http.ResponseWriter, r *http.Request) bool

func (*MockTFC) MakeGetApplyResponse

func (srv *MockTFC) MakeGetApplyResponse(apply tfe.Apply) map[string]interface{}

func (*MockTFC) MockRequest

func (srv *MockTFC) MockRequest(predicate mocking.RequestHandlerPredicate, h http.HandlerFunc)

MockRequest allows for requests to be mocked, which is especially useful if you want to test error cases. The predicate that you pass as the first argument can be used to make sure that you don't accidentally end up mocking the wrong request, such as the status update requests that agent instances send regularly in the background.

func (*MockTFC) PersistRun

func (srv *MockTFC) PersistRun(run *tfe.Run) *tfe.Run

func (*MockTFC) ServeHTTP

func (srv *MockTFC) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*MockTFC) SetRetryAfter

func (srv *MockTFC) SetRetryAfter(i int)

SetRetryAfter sets the value which will be used as the Retry-After header. This value will be used exactly once and discarded.

func (*MockTFC) SetToken

func (srv *MockTFC) SetToken(token string)

func (*MockTFC) SetUploadedArtifact

func (srv *MockTFC) SetUploadedArtifact(artifact []byte)

func (*MockTFC) Stop

func (srv *MockTFC) Stop()

func (*MockTFC) UploadedArtifact

func (srv *MockTFC) UploadedArtifact() []byte

type ProjectFactoryParameters

type ProjectFactoryParameters struct {
	Name string
}

type RunFactoryParameters

type RunFactoryParameters struct {
	RunStatus tfe.RunStatus
	Apply     *tfe.Apply
}

type RunPostRequest

type RunPostRequest struct {
	Data struct {
		Id         int `json:"id"`
		Attributes struct {
			AutoApply bool `json:"auto-apply"`
			IsDestroy bool `json:"is-destroy"`
		} `json:"attributes"`
		Relationships struct {
			Workspace struct {
				Data struct {
					Id string `json:"id"`
				} `json:"data"`
			} `json:"workspace"`
		} `json:"relationships"`
	} `json:"data"`
}

type ServiceCatalogMetadata

type ServiceCatalogMetadata struct {
	ProductId            string
	ProvisionedProductId string
	ProductVersion       string
}

type VarUpdateOrCreateRequest

type VarUpdateOrCreateRequest struct {
	Data struct {
		Id         int `json:"id"`
		Attributes struct {
			Key      string           `json:"key"`
			Value    string           `json:"value"`
			Category tfe.CategoryType `json:"category"`
			HCL      bool             `json:"hcl"`
		} `json:"attributes"`
		Relationships struct {
			Workspace struct {
				Data struct {
					Id string `json:"id"`
				} `json:"data"`
			} `json:"workspace"`
		} `json:"relationships"`
	} `json:"data"`
}

type WorkspaceFactoryParameters

type WorkspaceFactoryParameters struct {
	Name string
}

type WorkspaceUpdateRequest

type WorkspaceUpdateRequest struct {
	Data struct {
		Id         int `json:"id"`
		Attributes struct {
			TerraformVersion string `json:"value"`
		} `json:"attributes"`
		Relationships struct{} `json:"relationships"`
	} `json:"data"`
}

Jump to

Keyboard shortcuts

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