Example #1
0
	var outputDir string
	var designPackage *codegen.Package
	var designPackagePath string
	var designPackageSource string

	var m *meta.Generator

	BeforeEach(func() {
		genfunc = ""
		debug = false
		designPackagePath = "design"
		designPackageSource = "package design"
		codegen.DesignPackagePath = designPackagePath
		var err error
		outputWorkspace, err = codegen.NewWorkspace("output")
		p, err := outputWorkspace.NewPackage("testOutput")
		Ω(err).ShouldNot(HaveOccurred())
		outputDir = p.Abs()
		designWorkspace, err = codegen.NewWorkspace("test")
		Ω(err).ShouldNot(HaveOccurred())
		compiledFiles = nil
		compileError = nil
	})

	JustBeforeEach(func() {
		if designPackagePath != "" {
			designPackage, err := designWorkspace.NewPackage(designPackagePath)
			Ω(err).ShouldNot(HaveOccurred())
			if designPackageSource != "" {
				file := designPackage.CreateSourceFile("design.go")
				err = ioutil.WriteFile(file.Abs(), []byte(designPackageSource), 0655)
Example #2
0
	. "github.com/onsi/gomega"
	"github.com/raphael/goa/design"
	"github.com/raphael/goa/goagen/codegen"
	"github.com/raphael/goa/goagen/gen_app"
)

var _ = Describe("ContextsWriter", func() {
	var writer *genapp.ContextsWriter
	var filename string
	var workspace *codegen.Workspace

	JustBeforeEach(func() {
		var err error
		workspace, err = codegen.NewWorkspace("test")
		Ω(err).ShouldNot(HaveOccurred())
		pkg, err := workspace.NewPackage("contexts")
		Ω(err).ShouldNot(HaveOccurred())
		src := pkg.CreateSourceFile("test.go")
		filename = src.Abs()
		writer, err = genapp.NewContextsWriter(filename)
		Ω(err).ShouldNot(HaveOccurred())
		codegen.TempCount = 0
	})

	AfterEach(func() {
		workspace.Delete()
	})

	Context("correctly configured", func() {
		var f *os.File
		BeforeEach(func() {
Example #3
0
		})
	})
})

var _ = Describe("Generate", func() {
	var gen *genschema.Generator
	var files []string
	var genErr error
	var workspace *codegen.Workspace
	var testPkg *codegen.Package

	BeforeEach(func() {
		var err error
		workspace, err = codegen.NewWorkspace("test")
		Ω(err).ShouldNot(HaveOccurred())
		testPkg, err = workspace.NewPackage("schematest")
		Ω(err).ShouldNot(HaveOccurred())
		os.Args = []string{"codegen", "--out=" + testPkg.Abs(), "--design=foo"}
	})

	JustBeforeEach(func() {
		var err error
		gen, err = genschema.NewGenerator()
		Ω(err).ShouldNot(HaveOccurred())
		files, genErr = gen.Generate(design.Design)
	})

	AfterEach(func() {
		workspace.Delete()
	})