test

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

cmd/product/test/test.go

Index

Constants

This section is empty.

Variables

View Source
var TestCmd = &cobra.Command{
	DisableFlagParsing: true,
	Use:                "test [args...]",
	Example: `  contextvibes product test
  contextvibes product test -v  # Passes '-v' to 'go test' or 'pytest'
  contextvibes product test tests/my_specific_test.py # Passes path to pytest`,
	RunE: func(cmd *cobra.Command, args []string) error {
		presenter := ui.NewPresenter(cmd.OutOrStdout(), cmd.ErrOrStderr())
		ctx := cmd.Context()

		presenter.Summary("Running project tests.")

		cwd, err := os.Getwd()
		if err != nil {
			presenter.Error("Failed to get current working directory: %v", err)
			return err
		}

		projType, err := project.Detect(cwd)
		if err != nil {
			presenter.Error("Failed to detect project type: %v", err)
			return err
		}
		presenter.Info("Detected project type: %s", presenter.Highlight(string(projType)))

		var testErr error
		testExecuted := false

		switch projType {
		case project.Go:
			presenter.Header("Go Project Tests")
			testErr = executeGoTests(ctx, presenter, globals.ExecClient, cwd, args)
			testExecuted = true
		case project.Python:
			presenter.Header("Python Project Tests")
			testErr = executePythonTests(ctx, presenter, globals.ExecClient, cwd, args)
			testExecuted = true
		default:
			presenter.Info("No specific test execution logic for project type: %s", projType)
		}

		presenter.Newline()
		if !testExecuted && testErr == nil {
			presenter.Info("No tests were executed.")
			return nil
		}

		if testErr != nil {
			presenter.Error("Project tests failed.")
			return testErr
		}

		presenter.Success("Project tests completed successfully.")
		return nil
	},
}

TestCmd represents the test command

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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