forked from skynetservices/skynet-archive
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e8c7d1b
commit 4862f7a
Showing
2 changed files
with
76 additions
and
7 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
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,66 @@ | |||
package skylib | |||
|
|||
import ( | |||
"testing" | |||
"os" | |||
) | |||
|
|||
func TestGetServiceConfigFromFlags(t *testing.T) { | |||
os.Args = []string {"test", "--port=1234", "--address=localhost", "--region=TestRegion", "--doozer=localhost:8046", "--doozerboot=localhost:1232", "--autodiscover=true"} | |||
|
|||
config := GetServiceConfigFromFlags() | |||
|
|||
if config.ServiceAddr.IPAddress != "localhost" { | |||
t.Error("Address not set through flag") | |||
} | |||
|
|||
if config.ServiceAddr.Port != 1234 { | |||
t.Error("Port not set through flag") | |||
} | |||
|
|||
if config.Region != "TestRegion" { | |||
t.Error("Region not set through flag") | |||
} | |||
|
|||
if config.DoozerConfig.Uri != "localhost:8046" { | |||
t.Error("DoozerUri not set through flag") | |||
} | |||
|
|||
if config.DoozerConfig.BootUri != "localhost:1232" { | |||
t.Error("DoozerBootUri not set through flag") | |||
} | |||
|
|||
if config.DoozerConfig.AutoDiscover != true { | |||
t.Error("DoozerAutoDiscover not set through flag") | |||
} | |||
} | |||
|
|||
func TestGetServiceConfigFromFlagsDefaults(t *testing.T) { | |||
os.Args = []string {"test"} | |||
|
|||
config := GetServiceConfigFromFlags() | |||
|
|||
if config.ServiceAddr.IPAddress != "127.0.0.1" { | |||
t.Error("Address not set to default value") | |||
} | |||
|
|||
if config.ServiceAddr.Port != 9999 { | |||
t.Error("Port not set to default value") | |||
} | |||
|
|||
if config.Region != "unknown" { | |||
t.Error("Region not set to default value") | |||
} | |||
|
|||
if config.DoozerConfig.Uri != "127.0.0.1:8046" { | |||
t.Error("DoozerUri not set to default value") | |||
} | |||
|
|||
if config.DoozerConfig.BootUri != "127.0.0.1:8046" { | |||
t.Error("DoozerBootUri not set to default value") | |||
} | |||
|
|||
if config.DoozerConfig.AutoDiscover != true { | |||
t.Error("DoozerAutoDiscover not set to default value") | |||
} | |||
} |