Skip to content

Commit

Permalink
fixing golang install tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-pmillz committed Jun 9, 2022
1 parent 8384be9 commit 0969e4d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
13 changes: 0 additions & 13 deletions extra/extra.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ func InstallExtraPackages(osType string, dirs *localio.Directories, packages *lo
if err := localio.BrewInstallProgram("gnu-sed", "gsed", packages); err != nil {
return err
}
// install gotop
//if err := localio.BrewInstallProgram("gotop", "gotop", packages); err != nil {
// return err
//}
// install yamllint
if err := localio.BrewInstallProgram("yamllint", "yamllint", packages); err != nil {
return err
Expand Down Expand Up @@ -106,15 +102,6 @@ func InstallExtraPackages(osType string, dirs *localio.Directories, packages *lo
return err
}
}
// install gotop
//if _, exists := localio.CommandExists("go"); exists {
// if _, exists = localio.CommandExists("gotop"); !exists {
// if err := localio.RunCommandPipeOutput("go install github.com/xxxserxxx/gotop/v4/cmd/gotop@latest"); err != nil {
// return err
// }
// }
//}

// install cowsay, bat, fd-find
if err := localio.AptInstall(packages, "cowsay", "bat", "fd-find"); err != nil {
return err
Expand Down
8 changes: 7 additions & 1 deletion extra/extra_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,16 @@ func TestInstallExtraPackages(t *testing.T) {
if err != nil {
t.Errorf("failed to create Directories type: %v", err)
}

osType := runtime.GOOS
switch osType {
case "linux":
if err = localio.DownloadAndInstallLatestVersionOfGolang(dirs.HomeDir); err != nil {
packages, err := localio.NewAptInstalled()
if err != nil {
t.Errorf("failed to get AptInstalledPackages: %v", err)
}

if err = localio.DownloadAndInstallLatestVersionOfGolang(dirs.HomeDir, packages); err != nil {
t.Errorf("couldn't download and install golang: %v", err)
}
if err = localio.RunCommandPipeOutput("go version"); err != nil {
Expand Down
11 changes: 8 additions & 3 deletions localio/localio_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,19 +123,24 @@ func TestDownloadAndInstallLatestVersionOfGolang(t *testing.T) {
if err != nil {
t.Errorf("failed to create Directories type: %v", err)
}
pkgs, err := NewAptInstalled()
if err != nil {
t.Errorf("failed to get AptInstalledPackages: %v", err)
}
type args struct {
homeDir string
homeDir string
packages *InstalledPackages
}
tests := []struct {
name string
args args
wantErr bool
}{
{name: "TestDownloadAndInstallLatestVersionOfGolang 1", args: args{homeDir: dirs.HomeDir}, wantErr: false},
{name: "TestDownloadAndInstallLatestVersionOfGolang 1", args: args{homeDir: dirs.HomeDir, packages: pkgs}, wantErr: false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := DownloadAndInstallLatestVersionOfGolang(tt.args.homeDir); (err != nil) != tt.wantErr {
if err := DownloadAndInstallLatestVersionOfGolang(tt.args.homeDir, tt.args.packages); (err != nil) != tt.wantErr {
t.Errorf("DownloadAndInstallLatestVersionOfGolang() error = %v, wantErr %v", err, tt.wantErr)
}
})
Expand Down

0 comments on commit 0969e4d

Please sign in to comment.