tstmod

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2025 License: MIT Imports: 3 Imported by: 0

README

The tstmod package

The tstmod package provides a simple way to create a test module with two external dependencies:

  • github.com/ctx42/tst-a
  • github.com/ctx42/tst-b

These test modules are designed to validate the correctness of the package-finding mechanism in the mocker package, which is crucial for generating mocks. By creating a predictable module structure, tstmod lets me focus on testing how mocker discovers and processes dependencies, without the hassle of manually setting up test modules.

Test modules come in two versions, differing in dependency versions, as shown below:

tstmod-ver.png

This variation ensures I can thoroughly test mocker’s ability to handle different package versions correctly.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Module

type Module struct {
	Version string // Module version.
	Dir     string // Absolute path to the module root directory.
	// contains filtered or unexported fields
}

Module represents a test module used in tests.

Uses:

  • github.com/ctx42/tst-a@v0.1.0
  • github.com/ctx42/tst-b@v0.1.0
  • github.com/ctx42/tst-a@v0.2.0
  • github.com/ctx42/tst-b@v0.2.0

func New

func New(t tester.T, version string) *Module

New creates a new module in a temporary directory.

The version parameter must be one of the following:

  • "v1" - uses tst-a@v0.1.0 and tst-b@v0.1.0 modules.
  • "v2" - uses tst-a@v0.2.0 and tst-b@v0.2.0 modules.

func (*Module) CreateDir

func (mod *Module) CreateDir(pth string) string

CreateDir creates a new directory rooted at the project root directory.

func (*Module) Path

func (mod *Module) Path(elems ...string) string

Path returns a path described by elements rooted at the test module root.

func (*Module) WriteFile

func (mod *Module) WriteFile(pth, content string) string

WriteFile writes a file, rooted at the module's root directory, with the given name and content. Calls t.Fatal on error.

Jump to

Keyboard shortcuts

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