From 95ef4ce74ba3ba63bc21c9005dfba9cb7dbddc71 Mon Sep 17 00:00:00 2001 From: Aaron L <aaron@bettercoder.net> Date: Thu, 14 Jul 2016 22:44:52 -0700 Subject: [PATCH] Allow debug to be toggled by a flag. --- imports.go | 1 + templates_test/main_test/postgres_main.tpl | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/imports.go b/imports.go index 677c32b..c30a2ec 100644 --- a/imports.go +++ b/imports.go @@ -209,6 +209,7 @@ var defaultTestMainImports = map[string]imports{ `"testing"`, `"os"`, `"os/exec"`, + `"flag"`, `"fmt"`, `"io/ioutil"`, `"bytes"`, diff --git a/templates_test/main_test/postgres_main.tpl b/templates_test/main_test/postgres_main.tpl index f58a1f1..811103b 100644 --- a/templates_test/main_test/postgres_main.tpl +++ b/templates_test/main_test/postgres_main.tpl @@ -11,11 +11,13 @@ type Config struct { Postgres PostgresCfg `toml:"postgres"` } +var flagDebugMode = flag.Bool("test.sqldebug", false, "Turns on debug mode for SQL statements") + func TestMain(m *testing.M) { rand.Seed(time.Now().UnixNano()) // Set DebugMode so we can see generated sql statements - boil.DebugMode = false + boil.DebugMode = *flagDebugMode var err error if err = setup(); err != nil {