Skip to content

How to test executed commands #45

@lneves12

Description

@lneves12

Any tip on how to mock a command execution for testing?

I tried the trick from here: https://npf.io/2015/06/testing-exec-command/ but it's not working properly

// cmd.go tweak

var ComandExecuter = exec.Command

func (c *Cmd) run() {
	defer func() {
		c.statusChan <- c.Status() // unblocks Start if caller is waiting
		close(c.doneChan)
	}()

	// //////////////////////////////////////////////////////////////////////
	// Setup command
	// //////////////////////////////////////////////////////////////////////
	cmd := ComandExecuter(c.Name, c.Args...)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions