Skip to content

Commit

Permalink
Optimizing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Phillip Miller committed Oct 20, 2021
1 parent 3faf12a commit bb42262
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 7 deletions.
18 changes: 13 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## [v1.6.1](https://github.com/mr-pmillz/pimp-my-shell/tree/v1.6.1) (2021-10-20)

[Full Changelog](https://github.com/mr-pmillz/pimp-my-shell/compare/v1.6.0...v1.6.1)

## [v1.6.0](https://github.com/mr-pmillz/pimp-my-shell/tree/v1.6.0) (2021-10-20)

[Full Changelog](https://github.com/mr-pmillz/pimp-my-shell/compare/v1.5.9...v1.6.0)

## [v1.5.9](https://github.com/mr-pmillz/pimp-my-shell/tree/v1.5.9) (2021-10-20)

[Full Changelog](https://github.com/mr-pmillz/pimp-my-shell/compare/v1.5.8...v1.5.9)
Expand Down Expand Up @@ -38,15 +46,15 @@

## [v1.5.2](https://github.com/mr-pmillz/pimp-my-shell/tree/v1.5.2) (2021-10-17)

[Full Changelog](https://github.com/mr-pmillz/pimp-my-shell/compare/v1.4.5...v1.5.2)
[Full Changelog](https://github.com/mr-pmillz/pimp-my-shell/compare/v1.5.1...v1.5.2)

## [v1.4.5](https://github.com/mr-pmillz/pimp-my-shell/tree/v1.4.5) (2021-10-16)
## [v1.5.1](https://github.com/mr-pmillz/pimp-my-shell/tree/v1.5.1) (2021-10-16)

[Full Changelog](https://github.com/mr-pmillz/pimp-my-shell/compare/v1.5.1...v1.4.5)
[Full Changelog](https://github.com/mr-pmillz/pimp-my-shell/compare/v1.4.5...v1.5.1)

## [v1.5.1](https://github.com/mr-pmillz/pimp-my-shell/tree/v1.5.1) (2021-10-16)
## [v1.4.5](https://github.com/mr-pmillz/pimp-my-shell/tree/v1.4.5) (2021-10-16)

[Full Changelog](https://github.com/mr-pmillz/pimp-my-shell/compare/v1.5.0...v1.5.1)
[Full Changelog](https://github.com/mr-pmillz/pimp-my-shell/compare/v1.5.0...v1.4.5)

## [v1.5.0](https://github.com/mr-pmillz/pimp-my-shell/tree/v1.5.0) (2021-10-16)

Expand Down
2 changes: 1 addition & 1 deletion cheat/cheat.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func InstallCheat(osType string, dirs *localio.Directories, packages *localio.In
}
if _, exists := localio.CommandExists("cheat"); !exists {
fmt.Println("[+] Installing cheat")
if _, exists = localio.CommandExists("go"); !exists {
if _, exists = localio.CommandExists("go"); exists {
if cheatConfigExists, err := localio.Exists("~/.config/cheat"); err == nil && !cheatConfigExists {
if err := localio.RunCommandPipeOutput("go get -u github.com/cheat/cheat/cmd/cheat"); err != nil {
return err
Expand Down
16 changes: 16 additions & 0 deletions localio/localio_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -623,3 +623,19 @@ func TestRunCommands(t *testing.T) {
})
}
}

func TestStartTmuxSession(t *testing.T) {
tests := []struct {
name string
wantErr bool
}{
{name: "TestStartTmuxSession", wantErr: false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := StartTmuxSession(); (err != nil) != tt.wantErr {
t.Errorf("StartTmuxSession() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}
17 changes: 17 additions & 0 deletions tmux/tmux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,23 @@ func TestInstallOhMyTmux(t *testing.T) {
}
}

func Test_runTmux(t *testing.T) {
tests := []struct {
name string
wantErr bool
}{
{name: "Test_runTmux 1", wantErr: true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := runTmux(); (err != nil) != tt.wantErr {
t.Errorf("runTmux() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}


func TestStartTMUX(t *testing.T) {
tests := []struct {
name string
Expand Down
2 changes: 1 addition & 1 deletion vim/vim.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func InstallVimPlugins(osType string, dirs *localio.Directories) error {

// InstallVimAwesome ...
func InstallVimAwesome(osType string, dirs *localio.Directories, packages *localio.InstalledPackages) error {
if exists, err := localio.Exists(fmt.Sprintf("%s/.vim_runtime", dirs.HomeDir)); err == nil && exists == true {
if exists, err := localio.Exists(fmt.Sprintf("%s/.vim_runtime", dirs.HomeDir)); err == nil && exists {
return nil
}

Expand Down
7 changes: 7 additions & 0 deletions vim/vim_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package vim

import (
"fmt"
"os"
"pimp-my-shell/localio"
"testing"
"time"
Expand Down Expand Up @@ -59,6 +61,11 @@ func TestInstallVimAwesome(t *testing.T) {
dirs *localio.Directories
packages *localio.InstalledPackages
}
if val, _ := os.LookupEnv("GITHUB_ACTIONS"); val == "true" {
if err = localio.RunCommandPipeOutput(fmt.Sprintf("rm -rf %s/.vim_runtime", dirs.HomeDir)); err != nil {
t.Errorf("couldn't remove ~/.vim_runtime dir. error = %v", err)
}
}
tests := []struct {
name string
args args
Expand Down
6 changes: 6 additions & 0 deletions zsh/zsh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package zsh

import (
"fmt"
"os"
"pimp-my-shell/localio"
"runtime"
"testing"
Expand Down Expand Up @@ -56,6 +57,11 @@ func TestInstallOhMyZsh(t *testing.T) {
}
packages.AptInstalledPackages = &localio.AptInstalled{Name: []string{"bat"}}

if val, _ := os.LookupEnv("GITHUB_ACTIONS"); val == "true" {
if err = localio.RunCommandPipeOutput(fmt.Sprintf("rm -rf %s/.oh-my-zsh", dirs.HomeDir)); err != nil {
t.Errorf("couldn't remove ~/.vim_runtime dir. error = %v", err)
}
}
osType := runtime.GOOS
switch osType {
case "linux":
Expand Down

0 comments on commit bb42262

Please sign in to comment.