projecttestutil

package
v0.0.0-...-09edcb8 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TestTypingsLocation = "/home/src/Library/Caches/typescript"
)

Variables

This section is empty.

Functions

func TypesRegistryConfig

func TypesRegistryConfig() map[string]string

func TypesRegistryConfigText

func TypesRegistryConfigText() string

func WithRequestID

func WithRequestID(ctx context.Context) context.Context

Types

type ClientMock

type ClientMock struct {
	// RefreshDiagnosticsFunc mocks the RefreshDiagnostics method.
	RefreshDiagnosticsFunc func(ctx context.Context) error

	// UnwatchFilesFunc mocks the UnwatchFiles method.
	UnwatchFilesFunc func(ctx context.Context, id project.WatcherID) error

	// WatchFilesFunc mocks the WatchFiles method.
	WatchFilesFunc func(ctx context.Context, id project.WatcherID, watchers []*lsproto.FileSystemWatcher) error
	// contains filtered or unexported fields
}

ClientMock is a mock implementation of project.Client.

func TestSomethingThatUsesClient(t *testing.T) {

	// make and configure a mocked project.Client
	mockedClient := &ClientMock{
		RefreshDiagnosticsFunc: func(ctx context.Context) error {
			panic("mock out the RefreshDiagnostics method")
		},
		UnwatchFilesFunc: func(ctx context.Context, id project.WatcherID) error {
			panic("mock out the UnwatchFiles method")
		},
		WatchFilesFunc: func(ctx context.Context, id project.WatcherID, watchers []*lsproto.FileSystemWatcher) error {
			panic("mock out the WatchFiles method")
		},
	}

	// use mockedClient in code that requires project.Client
	// and then make assertions.

}

func (*ClientMock) RefreshDiagnostics

func (mock *ClientMock) RefreshDiagnostics(ctx context.Context) error

RefreshDiagnostics calls RefreshDiagnosticsFunc.

func (*ClientMock) RefreshDiagnosticsCalls

func (mock *ClientMock) RefreshDiagnosticsCalls() []struct {
	Ctx context.Context
}

RefreshDiagnosticsCalls gets all the calls that were made to RefreshDiagnostics. Check the length with:

len(mockedClient.RefreshDiagnosticsCalls())

func (*ClientMock) UnwatchFiles

func (mock *ClientMock) UnwatchFiles(ctx context.Context, id project.WatcherID) error

UnwatchFiles calls UnwatchFilesFunc.

func (*ClientMock) UnwatchFilesCalls

func (mock *ClientMock) UnwatchFilesCalls() []struct {
	Ctx context.Context
	ID  project.WatcherID
}

UnwatchFilesCalls gets all the calls that were made to UnwatchFiles. Check the length with:

len(mockedClient.UnwatchFilesCalls())

func (*ClientMock) WatchFiles

func (mock *ClientMock) WatchFiles(ctx context.Context, id project.WatcherID, watchers []*lsproto.FileSystemWatcher) error

WatchFiles calls WatchFilesFunc.

func (*ClientMock) WatchFilesCalls

func (mock *ClientMock) WatchFilesCalls() []struct {
	Ctx      context.Context
	ID       project.WatcherID
	Watchers []*lsproto.FileSystemWatcher
}

WatchFilesCalls gets all the calls that were made to WatchFiles. Check the length with:

len(mockedClient.WatchFilesCalls())

type NpmExecutorMock

type NpmExecutorMock struct {
	// NpmInstallFunc mocks the NpmInstall method.
	NpmInstallFunc func(cwd string, args []string) ([]byte, error)
	// contains filtered or unexported fields
}

NpmExecutorMock is a mock implementation of ata.NpmExecutor.

func TestSomethingThatUsesNpmExecutor(t *testing.T) {

	// make and configure a mocked ata.NpmExecutor
	mockedNpmExecutor := &NpmExecutorMock{
		NpmInstallFunc: func(cwd string, args []string) ([]byte, error) {
			panic("mock out the NpmInstall method")
		},
	}

	// use mockedNpmExecutor in code that requires ata.NpmExecutor
	// and then make assertions.

}

func (*NpmExecutorMock) NpmInstall

func (mock *NpmExecutorMock) NpmInstall(cwd string, args []string) ([]byte, error)

NpmInstall calls NpmInstallFunc.

func (*NpmExecutorMock) NpmInstallCalls

func (mock *NpmExecutorMock) NpmInstallCalls() []struct {
	Cwd  string
	Args []string
}

NpmInstallCalls gets all the calls that were made to NpmInstall. Check the length with:

len(mockedNpmExecutor.NpmInstallCalls())

type SessionUtils

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

func Setup

func Setup(files map[string]any) (*project.Session, *SessionUtils)

func SetupWithOptions

func SetupWithOptions(files map[string]any, options *project.SessionOptions) (*project.Session, *SessionUtils)

func SetupWithOptionsAndTypingsInstaller

func SetupWithOptionsAndTypingsInstaller(files map[string]any, options *project.SessionOptions, tiOptions *TypingsInstallerOptions) (*project.Session, *SessionUtils)

func SetupWithTypingsInstaller

func SetupWithTypingsInstaller(files map[string]any, tiOptions *TypingsInstallerOptions) (*project.Session, *SessionUtils)

func (*SessionUtils) BaselineLogs

func (h *SessionUtils) BaselineLogs(t *testing.T)

func (*SessionUtils) Client

func (h *SessionUtils) Client() *ClientMock

func (*SessionUtils) FS

func (h *SessionUtils) FS() vfs.FS

func (*SessionUtils) Logs

func (h *SessionUtils) Logs() string

func (*SessionUtils) NpmExecutor

func (h *SessionUtils) NpmExecutor() *NpmExecutorMock

func (*SessionUtils) SetupNpmExecutorForTypingsInstaller

func (h *SessionUtils) SetupNpmExecutorForTypingsInstaller()

type TypingsInstallerOptions

type TypingsInstallerOptions struct {
	TypesRegistry []string
	PackageToFile map[string]string
}

Jump to

Keyboard shortcuts

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