testutils

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TestCases = []TestCase{
	{
		Name:     "Standard Mode Crawl",
		Target:   "",
		Args:     "-depth 2 -silent",
		Expected: nil,
		CompareFunc: func(target string, got []string) error {
			if len(got) < 3 {
				return errkit.Newf("expected at least 3 URLs, got %d: %v", len(got), got)
			}
			expectedPaths := []string{"/about", "/contact", "/blog"}
			for _, path := range expectedPaths {
				found := false
				for _, u := range got {
					if strings.Contains(u, path) {
						found = true
						break
					}
				}
				if !found {
					return errkit.Newf("expected %s in output, got: %s", path, strings.Join(got, "\n"))
				}
			}
			return nil
		},
	},
	{
		Name:     "Standard Mode Depth 3",
		Target:   "",
		Args:     "-depth 3 -silent",
		Expected: nil,
		CompareFunc: func(target string, got []string) error {
			expectedPaths := []string{"/blog/post-1", "/blog/post-2", "/team"}
			for _, path := range expectedPaths {
				found := false
				for _, u := range got {
					if strings.Contains(u, path) {
						found = true
						break
					}
				}
				if !found {
					return errkit.Newf("depth 3 should discover %s, got: %s", path, strings.Join(got, "\n"))
				}
			}
			return nil
		},
	},
	{
		Name:     "Headless Browser Crawl",
		Target:   "",
		Args:     "-headless -no-incognito -depth 2 -silent -no-sandbox",
		Expected: nil,
		CompareFunc: func(target string, got []string) error {
			if len(got) < 2 {
				return errkit.Newf("expected at least 2 URLs in headless mode, got %d: %v", len(got), got)
			}
			for _, res := range got {
				if strings.Contains(res, target) {
					return nil
				}
			}
			return errkit.Newf("expected %v target in output, but got %v", target, strings.Join(got, "\n"))
		},
	},
}

Functions

func CompareOutput

func CompareOutput(input, expected []string) bool

func RunKatanaBinaryAndGetResults

func RunKatanaBinaryAndGetResults(target string, katanaBinary string, debug bool, args []string) ([]string, error)

Types

type TestCase

type TestCase struct {
	Name        string
	Target      string
	Args        string
	Expected    []string
	CompareFunc func(target string, got []string) error
}

func AuthTestCases added in v1.8.0

func AuthTestCases(labURL, flowPath string) []TestCase

AuthTestCases returns functional cases that exercise recorded-flow login against a running authlab instance. flowPath must point at a Chrome Recorder (or explicit steps) JSON file whose navigate URL targets that lab.

type TestServer added in v1.6.0

type TestServer struct {
	URL string
	// contains filtered or unexported fields
}

TestServer is a local HTTP server for functional tests.

func NewTestServer added in v1.6.0

func NewTestServer() (*TestServer, error)

NewTestServer starts a local HTTP server on a random port with a small site structure suitable for crawl testing.

func (*TestServer) Close added in v1.6.0

func (ts *TestServer) Close() error

Close shuts down the test server.

Directories

Path Synopsis
Package authlab provides a self-hosted mini web app used to exercise Katana recorded-flow / auto-login authentication end-to-end.
Package authlab provides a self-hosted mini web app used to exercise Katana recorded-flow / auto-login authentication end-to-end.

Jump to

Keyboard shortcuts

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