github.com/getgauge/gauge@v1.6.9/api/apiMessageHandler_test.go (about) 1 /*---------------------------------------------------------------- 2 * Copyright (c) ThoughtWorks, Inc. 3 * Licensed under the Apache License, Version 2.0 4 * See LICENSE in the project root for license information. 5 *----------------------------------------------------------------*/ 6 7 package api 8 9 import ( 10 "testing" 11 12 "github.com/getgauge/gauge-proto/go/gauge_messages" 13 "github.com/getgauge/gauge/api/infoGatherer" 14 "github.com/getgauge/gauge/gauge" 15 "github.com/getgauge/gauge/parser" 16 . "gopkg.in/check.v1" 17 ) 18 19 func Test(t *testing.T) { TestingT(t) } 20 21 type MySuite struct{} 22 23 var _ = Suite(&MySuite{}) 24 25 func (s *MySuite) TestCreateSpecsResponseMessageFor(c *C) { 26 h := &gaugeAPIMessageHandler{} 27 m := h.createSpecsResponseMessageFor([]*infoGatherer.SpecDetail{ 28 { 29 Spec: &gauge.Specification{Heading: &gauge.Heading{Value: "Spec heading 1"}}, 30 Errs: []parser.ParseError{{Message: "Scenario1 not found"}, {Message: "Scenario2 not found"}}, 31 }, 32 { 33 Spec: &gauge.Specification{}, 34 Errs: []parser.ParseError{{Message: "Scenarios not found"}}, 35 }, 36 { 37 Spec: &gauge.Specification{Heading: &gauge.Heading{Value: "Spec heading 2"}}, 38 }, 39 }) 40 41 var nilSpec *gauge_messages.ProtoSpec 42 43 c.Assert(len(m.GetDetails()), Equals, 3) 44 c.Assert(len(m.GetDetails()[0].ParseErrors), Equals, 2) 45 c.Assert(m.GetDetails()[0].Spec.GetSpecHeading(), Equals, "Spec heading 1") 46 c.Assert(len(m.GetDetails()[1].ParseErrors), Equals, 1) 47 c.Assert(m.GetDetails()[1].GetSpec(), Equals, nilSpec) 48 c.Assert(len(m.GetDetails()[2].ParseErrors), Equals, 0) 49 c.Assert(m.GetDetails()[2].Spec.GetSpecHeading(), Equals, "Spec heading 2") 50 }