package pkg import ( "git.xdrm.io/go/nix-amer/internal/exec" "testing" ) /////////////////// MOCKUP START /////////////////// type MockupCommand struct { Out []byte Err error } func (c MockupCommand) Run() error { return c.Err } func (c MockupCommand) Output() ([]byte, error) { return c.Out, c.Err } type MockupExecutor struct { Out []byte Err error } func (d MockupExecutor) Command(cmd string, args ...string) exec.Command { return &MockupCommand{Out: d.Out, Err: d.Err} } /////////////////// MOCKUP END /////////////////// func TestUnknownManager(t *testing.T) { execctx := new(MockupExecutor) execctx.Err = nil execctx.Out = []byte{} _, err := Load("apt-put", execctx) if err != ErrUnknownManager { t.Errorf("expected <%s>, got <%s>", ErrUnknownManager, err) t.Fail() } } func TestKnownManager(t *testing.T) { execctx := new(MockupExecutor) execctx.Err = nil execctx.Out = []byte{} _, err := Load("apt-get", execctx) if err != nil { t.Errorf("unexpected error <%s>", err) t.Fail() } }