forked from goraz/onion
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add new way to load variables like flags library
add consul layer
- Loading branch information
1 parent
0789309
commit dad6859
Showing
16 changed files
with
397 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,17 @@ | ||
language: go | ||
dist: trusty | ||
go: | ||
- 1.1 | ||
- 1.2 | ||
- 1.3 | ||
- 1.4 | ||
- 1.5 | ||
- 1.7 | ||
- 1.8 | ||
- tip | ||
before_install: | ||
- go get -v github.com/smartystreets/goconvey | ||
- go get -v github.com/axw/gocov/gocov | ||
- go get -v github.com/mattn/goveralls | ||
- go get -v github.com/hashicorp/consul/testutil | ||
- if ! go get code.google.com/p/go.tools/cmd/cover; then go get golang.org/x/tools/cmd/cover; fi | ||
- go get -v github.com/hashicorp/consul | ||
- go get -v ./... | ||
script: | ||
- goveralls -v -service travis-ci -repotoken $COVERALLS_TOKEN || go test -v | ||
matrix: | ||
allow_failures: | ||
- go: 1.1 | ||
- goveralls -v -service travis-ci -repotoken $COVERALLS_TOKEN || go test -v ./... | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package consulloader | ||
|
||
import ( | ||
"testing" | ||
|
||
"fmt" | ||
|
||
"github.com/hashicorp/consul/api" | ||
"github.com/hashicorp/consul/testutil" | ||
. "github.com/smartystreets/goconvey/convey" | ||
. "gopkg.in/fzerorubigd/onion.v3" | ||
) | ||
|
||
func TestConsulLoader(t *testing.T) { | ||
// Create a test Consul server | ||
srv1, err := testutil.NewTestServer() | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
defer srv1.Stop() | ||
|
||
//// Create a secondary server, passing in configuration | ||
//// to avoid bootstrapping as we are forming a cluster. | ||
//srv2, err := testutil.NewTestServerConfig(func(c *testutil.TestServerConfig) { | ||
// c.Bootstrap = false | ||
//}) | ||
//if err != nil { | ||
// t.Fatal(err) | ||
//} | ||
//defer srv2.Stop() | ||
|
||
// Join the servers together | ||
//srv1.JoinLAN(t, srv2.LANAddr) | ||
|
||
Convey("Extra env in config", t, func() { | ||
client, err := api.NewClient( | ||
&api.Config{ | ||
HttpClient: srv1.HTTPClient, | ||
Address: srv1.HTTPAddr, | ||
}, | ||
) | ||
So(err, ShouldBeNil) | ||
|
||
o := New() | ||
layer := NewConsulLayer(client, "prefix") | ||
o.AddLazyLayer(layer) | ||
Convey("check data from env", func() { | ||
srv1.SetKV(t, "prefix/data/nested", []byte("TDN")) | ||
fmt.Println(string(srv1.GetKV(t, "prefix/data/nested"))) | ||
So(o.GetString("data.nested"), ShouldEqual, "TDN") | ||
}) | ||
|
||
Convey("check data not in env", func() { | ||
So(o.GetString("not.valid.data"), ShouldEqual, "") | ||
So(o.GetString(""), ShouldEqual, "") | ||
}) | ||
|
||
}) | ||
|
||
} |
Oops, something went wrong.