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

View File

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

View File

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