github.com/brycereitano/goa@v0.0.0-20170315073847-8ffa6c85e265/goagen/gen_controller/generator_test.go (about)

     1  package gencontroller_test
     2  
     3  import (
     4  	"github.com/goadesign/goa/design"
     5  	"github.com/goadesign/goa/goagen/gen_controller"
     6  	. "github.com/onsi/ginkgo"
     7  	. "github.com/onsi/gomega"
     8  )
     9  
    10  var _ = Describe("NewGenerator", func() {
    11  	var generator *gencontroller.Generator
    12  
    13  	var args = struct {
    14  		api       *design.APIDefinition
    15  		outDir    string
    16  		designPkg string
    17  		appPkg    string
    18  		force     bool
    19  		pkg       string
    20  		resource  string
    21  		noExample bool
    22  	}{
    23  		api: &design.APIDefinition{
    24  			Name: "test api",
    25  		},
    26  		outDir:    "out_dir",
    27  		designPkg: "design",
    28  		appPkg:    "app",
    29  		pkg:       "controller",
    30  		resource:  "controller",
    31  		force:     false,
    32  	}
    33  
    34  	Context("with options all options set", func() {
    35  		BeforeEach(func() {
    36  
    37  			generator = gencontroller.NewGenerator(
    38  				gencontroller.API(args.api),
    39  				gencontroller.OutDir(args.outDir),
    40  				gencontroller.DesignPkg(args.designPkg),
    41  				gencontroller.AppPkg(args.appPkg),
    42  				gencontroller.Pkg(args.pkg),
    43  				gencontroller.Resource(args.resource),
    44  				gencontroller.Force(args.force),
    45  			)
    46  		})
    47  
    48  		It("has all public properties set with expected value", func() {
    49  			Ω(generator).ShouldNot(BeNil())
    50  			Ω(generator.API.Name).Should(Equal(args.api.Name))
    51  			Ω(generator.OutDir).Should(Equal(args.outDir))
    52  			Ω(generator.DesignPkg).Should(Equal(args.designPkg))
    53  			Ω(generator.AppPkg).Should(Equal(args.appPkg))
    54  			Ω(generator.Pkg).Should(Equal(args.pkg))
    55  			Ω(generator.Resource).Should(Equal(args.resource))
    56  			Ω(generator.Force).Should(Equal(args.force))
    57  		})
    58  
    59  	})
    60  })