mirror of
https://github.com/chenasraf/sofmani.git
synced 2026-05-17 17:28:04 +00:00
42 lines
1.2 KiB
Go
Executable File
42 lines
1.2 KiB
Go
Executable File
package installer
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/chenasraf/sofmani/appconfig"
|
|
"github.com/chenasraf/sofmani/logger"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestGetInstaller(t *testing.T) {
|
|
config := &appconfig.AppConfig{}
|
|
logger.InitLogger(false)
|
|
installer := &appconfig.InstallerData{Type: appconfig.InstallerTypeBrew}
|
|
inst, err := GetInstaller(config, installer)
|
|
assert.NoError(t, err)
|
|
assert.NotNil(t, inst)
|
|
}
|
|
|
|
func TestInstallerWithDefaults(t *testing.T) {
|
|
opts := map[string]any{"key": "value"}
|
|
defaults := &appconfig.AppConfigDefaults{
|
|
Type: &map[appconfig.InstallerType]appconfig.InstallerData{
|
|
appconfig.InstallerTypeBrew: {Opts: &opts},
|
|
},
|
|
}
|
|
installer := &appconfig.InstallerData{Type: appconfig.InstallerTypeBrew, Opts: &map[string]any{}}
|
|
result := InstallerWithDefaults(installer, appconfig.InstallerTypeBrew, defaults)
|
|
assert.Equal(t, "value", (*result.Opts)["key"])
|
|
}
|
|
|
|
func TestRunInstaller(t *testing.T) {
|
|
config := &appconfig.AppConfig{}
|
|
mockInstaller := &MockInstaller{
|
|
data: &appconfig.InstallerData{Name: strPtr("test"), Type: appconfig.InstallerTypeBrew},
|
|
isInstalled: false,
|
|
}
|
|
result, err := RunInstaller(config, mockInstaller)
|
|
assert.NoError(t, err)
|
|
assert.NotNil(t, result)
|
|
}
|