apply some formatting fixes

This commit is contained in:
Kevin Schoon 2021-09-01 08:56:22 -04:00
parent 1ad3c18c8a
commit a7947a7cb7
3 changed files with 34 additions and 36 deletions

View File

@ -12,39 +12,39 @@ import (
) )
func checkErr(t *testing.T, err error) { func checkErr(t *testing.T, err error) {
if err != nil { if err != nil {
t.Helper() t.Helper()
t.Fatal(err) t.Fatal(err)
} }
} }
func initTestConfig(t *testing.T) (*pomo.Store, *pomo.Config) { func initTestConfig(t *testing.T) (*pomo.Store, *pomo.Config) {
tmpPath, err := ioutil.TempDir(os.TempDir(), "pomo-test") tmpPath, err := ioutil.TempDir(os.TempDir(), "pomo-test")
checkErr(t, err) checkErr(t, err)
config := &pomo.Config{ config := &pomo.Config{
DateTimeFmt: "2006-01-02 15:04", DateTimeFmt: "2006-01-02 15:04",
BasePath: tmpPath, BasePath: tmpPath,
DBPath: filepath.Join(tmpPath, "pomo.db"), DBPath: filepath.Join(tmpPath, "pomo.db"),
SocketPath: filepath.Join(tmpPath, "pomo.sock"), SocketPath: filepath.Join(tmpPath, "pomo.sock"),
IconPath: filepath.Join(tmpPath, "icon.png"), IconPath: filepath.Join(tmpPath, "icon.png"),
} }
store, err := pomo.NewStore(config.DBPath) store, err := pomo.NewStore(config.DBPath)
checkErr(t, err) checkErr(t, err)
checkErr(t, pomo.InitDB(store)) checkErr(t, pomo.InitDB(store))
return store, config return store, config
} }
func TestPomoCreate(t *testing.T) { func TestPomoCreate(t *testing.T) {
store, config := initTestConfig(t) store, config := initTestConfig(t)
cmd := New(config) cmd := New(config)
checkErr(t, cmd.Run([]string{"pomo", "create", "fuu"})) checkErr(t, cmd.Run([]string{"pomo", "create", "fuu"}))
// verify the task was created // verify the task was created
store.With(func(tx *sql.Tx) error { store.With(func(tx *sql.Tx) error {
task, err := store.ReadTask(tx, 1) task, err := store.ReadTask(tx, 1)
checkErr(t, err) checkErr(t, err)
if task.Message != "fuu" { if task.Message != "fuu" {
checkErr(t, fmt.Errorf("task should have message fuu, got %s", task.Message)) checkErr(t, fmt.Errorf("task should have message fuu, got %s", task.Message))
} }
return nil return nil
}) })
} }

View File

@ -126,7 +126,6 @@ func (t *TaskRunner) run() error {
break break
} }
t.notifier.Notify("Pomo", "It is time to take a break!") t.notifier.Notify("Pomo", "It is time to take a break!")
// Reset the duration incase it // Reset the duration incase it
// was paused. // was paused.
@ -150,10 +149,10 @@ func (t *TaskRunner) Pause() {
func (t *TaskRunner) Status() *Status { func (t *TaskRunner) Status() *Status {
return &Status{ return &Status{
State: t.state, State: t.state,
Count: t.count, Count: t.count,
NPomodoros: t.nPomodoros, NPomodoros: t.nPomodoros,
Remaining: t.TimeRemaining(), Remaining: t.TimeRemaining(),
Pauseduration: t.TimePauseDuration(), Pauseduration: t.TimePauseDuration(),
} }
} }

View File

@ -7,7 +7,6 @@ import (
"github.com/fatih/color" "github.com/fatih/color"
) )
func SummerizeTasks(config *Config, tasks []*Task) { func SummerizeTasks(config *Config, tasks []*Task) {
for _, task := range tasks { for _, task := range tasks {
var start string var start string