Skip to content

Commit

Permalink
added numbers to env var pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
malud committed Jul 12, 2017
1 parent 246ed01 commit 3654b9a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ _testmain.go
*.exe
*.test
*.prof

/tg
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ sudo: required
go:
- 1.6.3
- 1.7
- 1.8.3
- tip
install:
- go get -d -v -t ./...
script:
- export GOMAXPROCS=$(nproc)
# - go test ./... -timeout=30s -parallel=4
- go test -v -timeout=30s ./...
- go build -o tg ./cli/cli.go
deploy:
provider: releases
Expand Down
2 changes: 1 addition & 1 deletion temgo/temgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

type EnvVars map[string]string

var templatePattern = regexp.MustCompile("{{\\s([A-Z_]*?)\\s}}")
var templatePattern = regexp.MustCompile("{{\\s([A-Z_0-9]*?)\\s}}")

func ContainsVariable(str []byte) bool {
return templatePattern.Match(str)
Expand Down
9 changes: 6 additions & 3 deletions temgo/temgo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ var containsTests = []struct {
{"This text contains a {{ VARIABLE }}.", true},
{"This text contains nothing.", false},
{"This text contains multiple {{ VAR }}{{ S }}.", true},
{"This text contains a variable with number {{ AUTH0_DOMAIN }}.", true},
}

var replaceVars = &temgo.EnvVars{
"VAR_A": "/etc/ptc",
"VARIABLE_C": "color:256",
"S": "short",
"VAR_A": "/etc/ptc",
"VARIABLE_C": "color:256",
"S": "short",
"AUTH0_DOMAIN": "samples.auth0.com",
}

var replaceTests = []struct {
Expand All @@ -28,6 +30,7 @@ var replaceTests = []struct {
{"Some text with a {{ VARIABLE_C }} variable!", "Some text with a color:256 variable!"},
{"This is a {{ S }} text.", "This is a short text."},
{"This is a {{ S }} text with a {{ FAILVAR}} and some vars [\"{{ VAR_A }}\",'{{ VARIABLE_C }}'].", "This is a short text with a {{ FAILVAR}} and some vars [\"/etc/ptc\",'color:256']."},
{"This text contains a variable with number: '{{ AUTH0_DOMAIN }}'.", "This text contains a variable with number: 'samples.auth0.com'."},
}

func TestContainsVariable(t *testing.T) {
Expand Down

0 comments on commit 3654b9a

Please sign in to comment.