-
Notifications
You must be signed in to change notification settings - Fork 0
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 #3 from opsfactory/tests/coverage
Tests and fixes by @fntlnz
- Loading branch information
Showing
9 changed files
with
139 additions
and
33 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
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,43 @@ | ||
package action | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/opsfactory/kappa/container" | ||
"github.com/opsfactory/kappa/container/label" | ||
) | ||
|
||
func TestActionString(t *testing.T) { | ||
ct := container.NewContainer() | ||
ct.Name = "john" | ||
ct.Backend = container.MesosBackend | ||
ct.Replicas = []string{} | ||
ct.NumReplicas = 0 | ||
ct.DesiredReplicas = 2 | ||
lbls := label.NewLabelContainer() | ||
lbls.Max = "10" | ||
lbls.Min = "1" | ||
lbls.Rate = "1" | ||
lbls.Metric = "mymetric" | ||
ct.Labels = lbls | ||
|
||
command := ScaleUp | ||
var unit ActionUnit | ||
unit = 1 | ||
a := Action{ | ||
Container: &ct, | ||
Command: command, | ||
Unit: unit, | ||
} | ||
|
||
estr := "Action{Container: Container{Name: john, Labels: LabelContainer{Min: 1, Max: 10, Rate: 1, Metric: mymetric}, Replicas: [], NumReplicas: 0, DesiredReplicas: 2, Backend: mesos}, Command: ScaleUP, Unit: 1}" | ||
|
||
res := a.String() | ||
if res != estr { | ||
t.Errorf( | ||
"Expected string and Action string does not match:\nExpected:%s\nGiven:%s", | ||
estr, | ||
res, | ||
) | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package event | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/opsfactory/kappa/container" | ||
) | ||
|
||
func TestNewContainerStartEvent(t *testing.T) { | ||
c := container.NewContainer() | ||
ev := NewContainerStartEvent(c) | ||
|
||
if ev.Type != ContainerStart { | ||
t.Error("event type should be `Start`, not: ", ev.Type) | ||
} | ||
} | ||
|
||
func TestNewContainerDieEvent(t *testing.T) { | ||
c := container.NewContainer() | ||
ev := NewContainerDieEvent(c) | ||
|
||
if ev.Type != ContainerDie { | ||
t.Error("event type should be `Die`, not: ", ev.Type) | ||
} | ||
} |
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,31 @@ | ||
package engine | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/opsfactory/kappa/container/action" | ||
"github.com/opsfactory/kappa/container/event" | ||
) | ||
|
||
type stubBackend struct { | ||
} | ||
|
||
func (b stubBackend) Monitor(eventsChan chan<- event.Event, errChan chan<- error) { | ||
errChan <- fmt.Errorf("I am meant to interrupt") | ||
} | ||
|
||
func (b stubBackend) Exec(eventsChan chan<- action.Action, errChan chan<- error) { | ||
|
||
} | ||
|
||
// TODO: update this tests once the actual Run function is in the process of being implemented | ||
func TestEngineRun(t *testing.T) { | ||
b := stubBackend{} | ||
e := NewEngine(b) | ||
res := e.Run() | ||
|
||
if res == nil { | ||
t.Error("An error was expected") | ||
} | ||
} |