37 lines
861 B
Go
37 lines
861 B
Go
package tests
|
|
|
|
import (
|
|
"errors"
|
|
"kerma/models"
|
|
"testing"
|
|
|
|
. "github.com/smartystreets/goconvey/convey"
|
|
)
|
|
|
|
func TestHello(t *testing.T) {
|
|
Convey("Given a new hello request", t, func() {
|
|
var hello models.Hello
|
|
|
|
Convey("When the Construct method is called", func() {
|
|
hello.Construct()
|
|
|
|
Convey("A correct hello request should be created", func() {
|
|
So(hello.Type, ShouldEqual, "hello")
|
|
So(hello.Version, ShouldEqual, "0.8.0")
|
|
So(hello.Agent, ShouldEqual, "BadKerma Go Client 0.8.x")
|
|
})
|
|
})
|
|
})
|
|
|
|
Convey("When an invalid request is created", t, func() {
|
|
var hello models.Hello
|
|
|
|
msgJSON := `{"type": "hello", "version": "0.9.0"}`
|
|
|
|
Convey("When UnmarshalJSON is called, it should return an error", func() {
|
|
err := errors.New("hello request not valid")
|
|
So(hello.UnmarshalJSON([]byte(msgJSON)), ShouldResemble, err)
|
|
})
|
|
})
|
|
}
|