Skip to content

Commit

Permalink
fix lint warnings. add mongo cluster test case.
Browse files Browse the repository at this point in the history
  • Loading branch information
lalabuy948 committed Aug 20, 2020
1 parent ae54dfe commit 9aefd54
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions gonvutils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,18 +148,18 @@ func TestParse(t *testing.T) {
type serverConfig struct {
// simple test
ServerPort string `genv:"SERVER_PORT,8080"`
MongoUrl string `genv:"MONGO_URL,mongodb://localhost:27017"`
MongoURL string `genv:"MONGO_URL, mongodb://localhost:27017"`

// string join test
MongoClusterUrl string `genv:"MONGO_URL,mongodb://mongodb,mongodb1,mongodb2/?replicaSet=rs0"`
MongoClusterURL string `genv:"MONGO_URL,mongodb://mongodb,mongodb1,mongodb2/?replicaSet=rs0"`

// edge cases
RedisUrl string `genv:""`
RedisPort int `genv:"REDIS_PORT, 6371"`
Compress bool `genv:"COMPRES, true"`
RedisURL string `genv:""`
RedisPort int `genv:"REDIS_PORT, 6371"`
Compress bool `genv:"COMPRES, true"`

// empty
Bla bool
Bla bool
}

var srvConf serverConfig
Expand All @@ -170,8 +170,11 @@ func TestParse(t *testing.T) {
if srvConf.ServerPort != "8080" {
t.Errorf("Parse(&srvConf) | ServerPort = %v; want 8080", srvConf.ServerPort)
}
if srvConf.MongoUrl != "mongodb://localhost:27017" {
t.Errorf("Parse(&srvConf) | MongoUrl = %v; want mongodb://localhost:27017", srvConf.MongoUrl)
if srvConf.MongoURL != "mongodb://localhost:27017" {
t.Errorf("Parse(&srvConf) | MongoURL = %v; want mongodb://localhost:27017", srvConf.MongoURL)
}
if srvConf.MongoClusterURL != "mongodb://mongodb,mongodb1,mongodb2/?replicaSet=rs0" {
t.Errorf("Parse(&srvConf) | MongoClusterURL = %v; want mongodb://mongodb,mongodb1,mongodb2/?replicaSet=rs0", srvConf.MongoClusterURL)
}
if srvConf.RedisPort != 6371 {
t.Errorf("Parse(&srvConf) | RedisPort = %v; want 6371 as int", srvConf.RedisPort)
Expand All @@ -190,8 +193,8 @@ func TestParse(t *testing.T) {
if srvConf.ServerPort != "8181" {
t.Errorf("Parse(&srvConf) | ServerPort = %v; want 8181", srvConf.ServerPort)
}
if srvConf.MongoUrl != "mongodb://localhost:76623" {
t.Errorf("Parse(&srvConf) | MongoUrl = %v; want mongodb://localhost:76623", srvConf.MongoUrl)
if srvConf.MongoURL != "mongodb://localhost:76623" {
t.Errorf("Parse(&srvConf) | MongoURL = %v; want mongodb://localhost:76623", srvConf.MongoURL)
}

os.Unsetenv("SERVER_PORT")
Expand Down

0 comments on commit 9aefd54

Please sign in to comment.