Skip to content

Commit

Permalink
Fix models generated test package (#505)
Browse files Browse the repository at this point in the history
  • Loading branch information
stanislas-m authored Dec 14, 2019
1 parent bcfc830 commit 394b898
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion genny/model/_fixtures/models/widget_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package models
package models_test

import "testing"

Expand Down
3 changes: 2 additions & 1 deletion genny/model/options.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package model

import (
"fmt"
"path/filepath"
"strings"

Expand Down Expand Up @@ -32,7 +33,7 @@ func (opts *Options) Validate() error {
opts.Package = filepath.Base(opts.Path)
}
if len(opts.TestPackage) == 0 {
opts.TestPackage = opts.Package
opts.TestPackage = fmt.Sprintf("%s_%s", opts.Package, "test")
}
if len(opts.Encoding) == 0 {
opts.Encoding = "json"
Expand Down
4 changes: 4 additions & 0 deletions genny/model/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ func Test_Options_Validate(t *testing.T) {
err = opts.Validate()
r.NoError(err)
r.Equal(0, len(opts.Attrs))
r.Equal("models", opts.Path)
r.Equal("models", opts.Package)
r.Equal("models_test", opts.TestPackage)
r.Equal("json", opts.Encoding)

// Force ID opt
opts.ForceDefaultID = true
Expand Down
1 change: 0 additions & 1 deletion packrd/packed-packr.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 394b898

Please sign in to comment.