Rename Single -> Singleton

- Remove some possible absolutely path nightmares
This commit is contained in:
Aaron L 2016-06-11 15:17:47 -07:00
parent d97e826265
commit 7bc9a4de1e
6 changed files with 21 additions and 15 deletions

View file

@ -75,9 +75,11 @@ func generateTestOutput(cmdData *CmdData, data *tplData) error {
return nil
}
func generateSinglesOutput(cmdData *CmdData) error {
// generateSingletonOutput processes the templates that should only be run
// one time.
func generateSingletonOutput(cmdData *CmdData) error {
if cmdData.SingleTemplates == nil {
return errors.New("No single templates located for generation")
return errors.New("No singleton templates located for generation")
}
tplData := &tplData{
@ -111,9 +113,11 @@ func generateSinglesOutput(cmdData *CmdData) error {
return nil
}
func generateSinglesTestOutput(cmdData *CmdData) error {
// generateSingletonTestOutput processes the templates that should only be run
// one time.
func generateSingletonTestOutput(cmdData *CmdData) error {
if cmdData.SingleTestTemplates == nil {
return errors.New("No single test templates located for generation")
return errors.New("No singleton test templates located for generation")
}
tplData := &tplData{

View file

@ -14,12 +14,12 @@ import (
)
const (
templatesDirectory = "/cmds/templates"
templatesSinglesDirectory = "/cmds/templates/singles"
templatesDirectory = "cmds/templates"
templatesSinglesDirectory = "cmds/templates/singleton"
templatesTestDirectory = "/cmds/templates_test"
templatesSinglesTestDirectory = "/cmds/templates_test/singles"
templatesTestMainDirectory = "/cmds/templates_test/main_test"
templatesTestDirectory = "cmds/templates_test"
templatesSinglesTestDirectory = "cmds/templates_test/singleton"
templatesTestMainDirectory = "cmds/templates_test/main_test"
)
// LoadTemplates loads all template folders into the cmdData object.
@ -125,8 +125,8 @@ func (c *CmdData) SQLBoilerRun(cmd *cobra.Command, args []string) error {
// run executes the sqlboiler templates and outputs them to files.
func (c *CmdData) run(includeTests bool) error {
if err := generateSinglesOutput(c); err != nil {
return fmt.Errorf("Unable to generate single templates output: %s", err)
if err := generateSingletonOutput(c); err != nil {
return fmt.Errorf("Unable to generate singleton template output: %s", err)
}
if includeTests {
@ -134,8 +134,8 @@ func (c *CmdData) run(includeTests bool) error {
return fmt.Errorf("Unable to generate TestMain output: %s", err)
}
if err := generateSinglesTestOutput(c); err != nil {
return fmt.Errorf("Unable to generate single test templates output: %s", err)
if err := generateSingletonTestOutput(c); err != nil {
return fmt.Errorf("Unable to generate singleton test template output: %s", err)
}
}

View file

@ -99,9 +99,9 @@ func TestTemplates(t *testing.T) {
t.Errorf("Templates is empty.")
}
cmdData.SingleTemplates, err = loadTemplates("templates/singles")
cmdData.SingleTemplates, err = loadTemplates("templates/singleton")
if err != nil {
t.Fatalf("Unable to initialize single templates: %s", err)
t.Fatalf("Unable to initialize singleton templates: %s", err)
}
if len(cmdData.SingleTemplates) == 0 {

View file

@ -52,6 +52,7 @@ type imports struct {
thirdparty importList
}
// PostgresCfg configures a postgres database
type PostgresCfg struct {
User string `toml:"user"`
Pass string `toml:"pass"`
@ -60,6 +61,7 @@ type PostgresCfg struct {
DBName string `toml:"dbname"`
}
// Config is loaded from a file
type Config struct {
Postgres PostgresCfg `toml:"postgres"`
}