-
-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
59 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
package appui | ||
|
||
type EventHandler func(string) error | ||
//EventCommand type alias for a func to be run by an Actionable | ||
type EventCommand func(string) error | ||
|
||
//Actionable interface describes how widgets run commands as a result of an event | ||
type Actionable interface { | ||
OnEvent(EventHandler) error | ||
OnEvent(EventCommand) error | ||
} |
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,51 @@ | ||
package appui | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/docker/docker/api/types/swarm" | ||
"github.com/moncho/dry/docker/formatter" | ||
) | ||
|
||
func TestTaskRow(t *testing.T) { | ||
task := swarm.Task{ | ||
ID: "task1", | ||
Annotations: swarm.Annotations{Name: "taskName"}, | ||
Spec: swarm.TaskSpec{}, | ||
} | ||
|
||
ts := formatter.NewTaskStringer(task) | ||
row := NewTaskRow(task) | ||
|
||
if row == nil { | ||
t.Error("TaskRow was not created") | ||
} | ||
|
||
if row.ID.Text != task.ID { | ||
t.Errorf("TaskRow name is not 'test', got %s", row.ID.Text) | ||
} | ||
|
||
if row.Name.Text != task.Name { | ||
t.Errorf("TaskRow name is not 'test', got %s", row.Name.Text) | ||
} | ||
|
||
if row.Image.Text != ts.Image() { | ||
t.Errorf("Unexpected TaskRow image, got %s, expected %s", row.Image.Text, ts.Image()) | ||
} | ||
if row.Node.Text != ts.NodeID() { | ||
t.Errorf("Unexpected TaskRow node, got %s, expected %s", row.Node.Text, ts.NodeID()) | ||
} | ||
if row.DesiredState.Text != ts.DesiredState() { | ||
t.Errorf("Unexpected TaskRow DesiredState, got %s, expected %s", row.DesiredState.Text, ts.DesiredState()) | ||
} | ||
if row.CurrentState.Text != ts.CurrentState() { | ||
t.Errorf("Unexpected TaskRow CurrentState, got %s, expected %s", row.CurrentState.Text, ts.CurrentState()) | ||
} | ||
if row.Error.Text != ts.Error() { | ||
t.Errorf("Unexpected TaskRow error, got %s, expected %s", row.Error.Text, ts.Error()) | ||
} | ||
if row.Ports.Text != ts.Ports() { | ||
t.Errorf("Unexpected TaskRow ports, got %s, expected %s", row.Ports.Text, ts.Ports()) | ||
|
||
} | ||
} |
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