Skip to content

Commit

Permalink
✅ Add update test on multiple checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Delni committed Jan 4, 2023
1 parent 6f2f22d commit abcdca5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/preflight/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package preflight

import (
"fmt"
"os"
"os/exec"
"preflight/src/io"
"runtime"
Expand All @@ -18,7 +17,7 @@ func (p PreflightModel) runCheckpoint() tea.Cmd {
interpreter, err := io.GetInterpreterCommand(runtime.GOOS)
if err != nil {
fmt.Println(err)
os.Exit(1)
return tea.Quit
}
interpreterArg := interpreter.InterpreterArgs
if checkpoint.UseInteractive {
Expand Down
27 changes: 26 additions & 1 deletion src/preflight/update_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package preflight

import "testing"
import (
"preflight/src/systemcheck"
"testing"
)

func TestUpdateInternalStateFinished(t *testing.T) {
p := makeTestModel()
Expand All @@ -11,3 +14,25 @@ func TestUpdateInternalStateFinished(t *testing.T) {
t.Errorf("got %+v", ans)
}
}

func TestUpdateInternalStateContinue(t *testing.T) {
p := makeTestModel()
p.checks = []systemcheck.SystemCheck{
testSystemCheck,
testSystemCheck,
}

ans, _ := p.UpdateInternalState(systemCheckMsg{check: true})

if ans.done != false {
t.Errorf("got %+v", ans.done)
}

if ans.activeIndex != 1 {
t.Errorf("got %+v", ans.activeIndex)
}

if ans.progress.Percent() != .5 {
t.Errorf("got %+v", ans.progress.Percent())
}
}

0 comments on commit abcdca5

Please sign in to comment.