-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from fumeapp/proper-error
🥅 we are not properly rendering errors in CI mode
- Loading branch information
Showing
8 changed files
with
177 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"github.com/fumeapp/taskin" | ||
"time" | ||
) | ||
|
||
func main() { | ||
|
||
tasks := taskin.New(taskin.Tasks{ | ||
{ | ||
Title: "Task 1", | ||
Task: func(t *taskin.Task) error { | ||
for i := 0; i < 3; i++ { | ||
t.Title = fmt.Sprintf("Task 1: [%d/3] seconds have passed", i+1) | ||
time.Sleep(500 * time.Millisecond) | ||
} | ||
return nil | ||
}, | ||
}, | ||
{ | ||
Title: "Task 2: Error", | ||
Task: func(t *taskin.Task) error { | ||
return fmt.Errorf("task 2 failed") | ||
}, | ||
}, | ||
{ | ||
Title: "Task 3", | ||
Task: func(t *taskin.Task) error { | ||
for i := 0; i < 3; i++ { | ||
t.Title = fmt.Sprintf("Task 3: [%d/3] seconds have passed", i+1) | ||
time.Sleep(500 * time.Millisecond) | ||
} | ||
return nil | ||
}, | ||
}, | ||
}, taskin.Defaults) | ||
// }, taskin.Config{Options: taskin.ConfigOptions{ExitOnFailure: false}}) | ||
err := tasks.Run() | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,38 @@ | ||
package taskin | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
) | ||
|
||
func TestRunners_Init(t *testing.T) { | ||
r := &Runners{ | ||
// Initialize your Runners struct here | ||
} | ||
func TestModelInit(t *testing.T) { | ||
// Initialize a new Model | ||
m := &Model{} | ||
|
||
cmd := r.Init() | ||
// Call the Init method | ||
cmd := m.Init() | ||
|
||
// If Init is not implemented, it should return nil | ||
// Check if the returned command is not nil | ||
if cmd != nil { | ||
t.Errorf("Expected Init to return nil") | ||
t.Errorf("Expected command to be not nil, got not nil") | ||
} | ||
} | ||
|
||
func TestRunners_View(t *testing.T) { | ||
r := &Runners{ | ||
// Initialize your Runners struct here | ||
} | ||
func TestModelUpdate(t *testing.T) { | ||
// Initialize a new Model | ||
m := &Model{} | ||
|
||
// Set the "CI" environment variable | ||
os.Setenv("CI", "true") | ||
// Call the Update method with a dummy message | ||
newModel, cmd := m.Update("dummy message") | ||
|
||
view := r.View() | ||
// Check if the returned model is not nil | ||
if newModel == nil { | ||
t.Errorf("Expected model to be not nil, got nil") | ||
} | ||
|
||
// If "CI" is set and not all tasks are completed, View should return an empty string | ||
if view != "" { | ||
t.Errorf("Expected View to return an empty string") | ||
// Check if the returned command is nil | ||
if cmd != nil { | ||
t.Errorf("Expected command to be nil, got non-nil") | ||
} | ||
} | ||
|
||
// Add more tests for other methods in the Model struct |
Oops, something went wrong.