Exemplo n.º 1
0
func TestTime(t *testing.T) {
	time := types.NewInsightsV3Time()

	Convey("WindowSize", t, func() {
		Convey("Should set correctly", func() {
			err := time.SetWindowSize("none")
			So(err, ShouldBeNil)

			err = time.SetWindowSize("invalid")
			So(err, ShouldNotBeNil)
		})

		Convey("should convert to Json correctly", func() {
			jsonBytes, err := json.Marshal(time)

			json := string(jsonBytes)

			So(err, ShouldBeNil)
			So(json, ShouldContainSubstring, "min")
			So(json, ShouldContainSubstring, "max")
			So(json, ShouldContainSubstring, `"window_size":"none"`)
		})
	})

}
Exemplo n.º 2
0
func TestTimeSet(t *testing.T) {
	query := types.NewInsightsV3Query()

	Convey("SetTimeCorrectly", t, func() {
		Convey("Be able to set the time", func() {
			time := types.NewInsightsV3Time()

			time.WindowSize = "hour"

			query.SetReportTime(time)

			So(query.Time.WindowSize, ShouldEqual, "hour")
		})
	})
}