testproxy

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package testproxy serves Go modules from a directory, the file-based GOPROXY layout, so tests can fetch and build remote plugins without the network and without touching the user's module cache.

Index

Constants

View Source
const Plugin = `//go:build wasip1

package main

import (
	"context"

	"code.rbel.co/rubiojr/gus/wasm/sdk"
)

type args struct {
	Name string ` + "`json:\"name\"`" + `
}

func init() {
	sdk.Tool("hello", "Say hello.", func(_ context.Context, a args) (any, error) {
		return "hello " + a.Name, nil
	})
}

func main() {}
`

Plugin is the source of a plugin with one tool, hello, that greets.

View Source
const SDKVersion = "v0.99.0"

SDKVersion is the version of code.rbel.co/rubiojr/gus the proxy serves: the SDK and the schema package of this checkout, nothing else.

Variables

This section is empty.

Functions

This section is empty.

Types

type Proxy

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

Proxy is a module proxy in a test's temporary directory.

func New

func New(t testing.TB) *Proxy

New starts an empty proxy with its own module cache.

func (*Proxy) Add

func (p *Proxy) Add(path, version string, files map[string]string)

Add publishes a module version with these files, go.mod included.

func (*Proxy) AddModule

func (p *Proxy) AddModule(path, version string, files map[string]string, extra string)

AddModule publishes a module that requires the SDK, with these files and a go.mod the go command tidies, so its go.sum is complete. extra is appended to the go.mod, for directives such as replace.

func (*Proxy) AddSDK

func (p *Proxy) AddSDK()

AddSDK publishes this checkout's plugin SDK as code.rbel.co/rubiojr/gus at SDKVersion.

func (*Proxy) Env

func (p *Proxy) Env() []string

Env is the environment for go commands that fetch from the proxy: nothing else is reachable, nothing is checked against the checksum database, and the module cache is the proxy's own, writable so the test can remove it.

Source Files