From ba8ec3f455cb19438ed81a1480d275aa629927fe Mon Sep 17 00:00:00 2001 From: Hunter Long Date: Sat, 17 Nov 2018 09:24:30 -0800 Subject: [PATCH] api postman testing - API updates --- Makefile | 4 ++++ core/configs.go | 24 +++++++++++++----------- core/notifier/notifiers.go | 1 + source/tmpl/form_notifier.html | 8 ++++---- 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 1fb265ca..baffc545 100644 --- a/Makefile +++ b/Makefile @@ -85,6 +85,10 @@ test: clean compile install build-plugin STATUP_DIR=$(TEST_DIR) go test -v -p=1 $(BUILDVERSION) -coverprofile=coverage.out ./... gocov convert coverage.out > coverage.json +test-api: + DB_CONN=sqlite statup & + sleep 15 && newman run source/tmpl/postman.json -e dev/postman_environment.json + # report coverage to Coveralls coverage: $(GOPATH)/bin/goveralls -coverprofile=coverage.out -service=travis -repotoken $(COVERALLS) diff --git a/core/configs.go b/core/configs.go index 151a9480..192ef427 100644 --- a/core/configs.go +++ b/core/configs.go @@ -55,17 +55,19 @@ func LoadUsingEnv() (*DbConfig, error) { if os.Getenv("DB_CONN") == "" { return nil, errors.New("Missing DB_CONN environment variable") } - if os.Getenv("DB_HOST") == "" { - return nil, errors.New("Missing DB_HOST environment variable") - } - if os.Getenv("DB_USER") == "" { - return nil, errors.New("Missing DB_USER environment variable") - } - if os.Getenv("DB_PASS") == "" { - return nil, errors.New("Missing DB_PASS environment variable") - } - if os.Getenv("DB_DATABASE") == "" { - return nil, errors.New("Missing DB_DATABASE environment variable") + if os.Getenv("DB_CONN") != "sqlite" { + if os.Getenv("DB_HOST") == "" { + return nil, errors.New("Missing DB_HOST environment variable") + } + if os.Getenv("DB_USER") == "" { + return nil, errors.New("Missing DB_USER environment variable") + } + if os.Getenv("DB_PASS") == "" { + return nil, errors.New("Missing DB_PASS environment variable") + } + if os.Getenv("DB_DATABASE") == "" { + return nil, errors.New("Missing DB_DATABASE environment variable") + } } Configs = EnvToConfig() CoreApp.Name = os.Getenv("NAME") diff --git a/core/notifier/notifiers.go b/core/notifier/notifiers.go index a57b3d76..d9638867 100644 --- a/core/notifier/notifiers.go +++ b/core/notifier/notifiers.go @@ -79,6 +79,7 @@ type NotificationForm struct { DbField string `json:"field"` // true variable key for input SmallText string `json:"small_text"` // insert small text under a html input Required bool `json:"required"` // require this input on the html form + Hidden bool `json:"hidden"` // hide this form element from end user } // NotificationLog contains the normalized message from previously sent notifications diff --git a/source/tmpl/form_notifier.html b/source/tmpl/form_notifier.html index 36d4bb5c..f4566d4f 100644 --- a/source/tmpl/form_notifier.html +++ b/source/tmpl/form_notifier.html @@ -6,14 +6,14 @@ {{range $n.Form}}
- + {{if eq .Type "textarea"}} - + {{else}} - + {{end}} {{if .SmallText}} - {{safe .SmallText}} + {{safe .SmallText}} {{end}}
{{end}}