e2e

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

README

E2E Tests

This directory contains end-to-end (E2E) tests for the Thalassa Cloud CLI. These tests execute the actual CLI binary against a real API endpoint to verify that commands work correctly.

Prerequisites

  1. Build the CLI binary:

    make build
    
  2. Set up authentication credentials. You need at least one of:

    • Personal Access Token
    • Access Token
    • OIDC Client ID and Secret

Configuration

E2E tests are configured using environment variables:

Required Variables
  • TCLOUD_E2E_API_ENDPOINT: The API endpoint URL (e.g., https://api.thalassa.cloud)
Authentication (at least one required)
  • TCLOUD_E2E_PERSONAL_ACCESS_TOKEN: Personal access token for authentication
  • TCLOUD_E2E_ACCESS_TOKEN: Access token for authentication
  • TCLOUD_E2E_OIDC_CLIENT_ID + TCLOUD_E2E_OIDC_CLIENT_SECRET: OIDC credentials
Optional Variables
  • TCLOUD_E2E_ORGANISATION: Organisation slug or identity to use for tests
  • TCLOUD_E2E_BINARY_PATH: Path to the CLI binary (defaults to ./bin/tcloud)

Running Tests

Run all E2E tests
go test ./e2e/... -v
Run specific test
go test ./e2e/... -v -run TestVersion
Run with environment variables
export TCLOUD_E2E_API_ENDPOINT="https://api.thalassa.cloud"
export TCLOUD_E2E_PERSONAL_ACCESS_TOKEN="your-token"
go test ./e2e/... -v
Using a .env file

You can create a .env file in the project root and source it:

source .env
go test ./e2e/... -v

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandResult

type CommandResult struct {
	Stdout   string
	Stderr   string
	ExitCode int
	Error    error
}

CommandResult holds the result of a command execution

func (*CommandResult) AssertFailure

func (r *CommandResult) AssertFailure(t *testing.T)

AssertFailure asserts that the command failed

func (*CommandResult) AssertStderrContains

func (r *CommandResult) AssertStderrContains(t *testing.T, substr string)

AssertStderrContains asserts that stderr contains the given string

func (*CommandResult) AssertStdoutContains

func (r *CommandResult) AssertStdoutContains(t *testing.T, substr string)

AssertStdoutContains asserts that stdout contains the given string

func (*CommandResult) AssertStdoutNotContains

func (r *CommandResult) AssertStdoutNotContains(t *testing.T, substr string)

AssertStdoutNotContains asserts that stdout does not contain the given string

func (*CommandResult) AssertSuccess

func (r *CommandResult) AssertSuccess(t *testing.T)

AssertSuccess asserts that the command succeeded

func (*CommandResult) GetLines

func (r *CommandResult) GetLines() []string

GetLines returns stdout split into lines

func (*CommandResult) PrintOutput

func (r *CommandResult) PrintOutput(t *testing.T)

PrintOutput prints the command output for debugging

type TestConfig

type TestConfig struct {
	APIEndpoint         string
	AccessToken         string
	PersonalAccessToken string
	OIDCClientID        string
	OIDCClientSecret    string
	Organisation        string
	BinaryPath          string
}

TestConfig holds configuration for E2E tests

func LoadTestConfig

func LoadTestConfig(t *testing.T) *TestConfig

LoadTestConfig loads test configuration from environment variables

func (*TestConfig) CreateSubnet

func (c *TestConfig) CreateSubnet(t *testing.T, vpcIdentity string) string

CreateSubnet creates a subnet in the given VPC for testing and registers cleanup It uses a unique CIDR based on timestamp to avoid conflicts

func (*TestConfig) CreateVPC

func (c *TestConfig) CreateVPC(t *testing.T) string

CreateVPC creates a VPC for testing and registers cleanup

func (*TestConfig) GetRegion

func (c *TestConfig) GetRegion(t *testing.T) string

GetRegion gets a valid region from the API for use in tests

func (*TestConfig) GetVPC

func (c *TestConfig) GetVPC(t *testing.T) string

GetVPC gets a valid VPC from the API for use in tests If no VPC exists, it creates one and registers cleanup

func (*TestConfig) GetVolume

func (c *TestConfig) GetVolume(t *testing.T) string

GetVolume gets a valid volume from the API for use in tests

func (*TestConfig) RunCommand

func (c *TestConfig) RunCommand(t *testing.T, args ...string) *CommandResult

RunCommand executes a CLI command and returns the result

func (*TestConfig) SkipIfNotConfigured

func (c *TestConfig) SkipIfNotConfigured(t *testing.T)

SkipIfNotConfigured skips the test if required configuration is missing

Jump to

Keyboard shortcuts

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