Archived
2
0
This repository has been archived on 2023-03-02. You can view files and clone it, but cannot push or open issues or pull requests.
kerma/models/tests/hello_test.go
2023-03-02 15:28:43 +01:00

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)
})
})
}