installer

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Example (InstallItemFailure)
// Override execCommand and checkStatus with our fake versions
execCommand = fakeExecCommand
statusCheckStatus = fakeCheckStatus
runCommand = fakeRunCommand
download.SetConfig(downloadCfg)
defer func() {
	execCommand = origExec
	statusCheckStatus = origCheckStatus
	runCommand = origRunCommand
}()

// Set shared testing variables
cachePath := "testdata/"
urlPackages := "https://example.com/"

//
// Msi
//
msiItem.DisplayName = statusActionError

//

// Run Install
installItem(msiItem, urlPackages, cachePath)
Output:

Installing msi for _gorilla_dev_action_error_
_gorilla_dev_action_error_ 1.2.3 Installation FAILED
Example (InstallItemSuccess)
// Override execCommand and checkStatus with our fake versions
execCommand = fakeExecCommand
statusCheckStatus = fakeCheckStatus
runCommand = fakeRunCommand
download.SetConfig(downloadCfg)
defer func() {
	execCommand = origExec
	statusCheckStatus = origCheckStatus
	runCommand = origRunCommand
}()

// Set shared testing variables
cachePath := "testdata/"
urlPackages := "https://example.com/"

//
// Msi
//
msiItem.DisplayName = statusActionNoError

//

// Run Install
installItem(msiItem, urlPackages, cachePath)
Output:

Installing msi for _gorilla_dev_action_noerror_
_gorilla_dev_action_noerror_ 1.2.3 Installation SUCCESSFUL
Example (RunCommand)

Example_runCommand tests the output when running a command in debug

// Temp directory for logging
logTmp, _ := ioutil.TempDir("", "gorilla-installer_test")

// Setup a testing Configuration struct with debug mode
cfgVerbose := config.Configuration{
	Debug:       true,
	Verbose:     true,
	AppDataPath: logTmp,
}

// Start gorillalog in debug mode
gorillalog.NewLog(cfgVerbose)

// Override execCommand with our fake version
execCommand = fakeExecCommand
defer func() { execCommand = origExec }()

// Set up what we expect
testCmd := "Command Test!"
testArgs := []string{"arg1", "arg2"}

// Run the function
runCommand(testCmd, testArgs)
Output:

command: Command Test! [arg1 arg2]
Command Output:
--------------------
[Command Test! arg1 arg2]
--------------------
Example (UninstallItemFailure)
// Override execCommand and checkStatus with our fake versions
execCommand = fakeExecCommand
statusCheckStatus = fakeCheckStatus
runCommand = fakeRunCommand
download.SetConfig(downloadCfg)
defer func() {
	execCommand = origExec
	statusCheckStatus = origCheckStatus
	runCommand = origRunCommand
}()

// Set shared testing variables
cachePath := "testdata/"
urlPackages := "https://example.com/"

//
// Msi
//
msiItem.DisplayName = statusActionError

// Run Install
uninstallItem(msiItem, urlPackages, cachePath)
Output:

Uninstalling msi for _gorilla_dev_action_error_
_gorilla_dev_action_error_ 1.2.3 Uninstallation FAILED
Example (UninstallItemSuccess)
// Override execCommand and checkStatus with our fake versions
execCommand = fakeExecCommand
statusCheckStatus = fakeCheckStatus
runCommand = fakeRunCommand
download.SetConfig(downloadCfg)
defer func() {
	execCommand = origExec
	statusCheckStatus = origCheckStatus
	runCommand = origRunCommand
}()

// Set shared testing variables
cachePath := "testdata/"
urlPackages := "https://example.com/"

//
// Msi
//
msiItem.DisplayName = statusActionNoError

// Run Install
uninstallItem(msiItem, urlPackages, cachePath)
Output:

Uninstalling msi for _gorilla_dev_action_noerror_
_gorilla_dev_action_noerror_ 1.2.3 Uninstallation SUCCESSFUL

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Install

func Install(item catalog.Item, installerType, urlPackages, cachePath string, checkOnly bool) string

Install determines if action needs to be taken on a item and then calls the appropriate function to install or uninstall

Types

This section is empty.

Jump to

Keyboard shortcuts

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