diff --git a/config.go b/config.go index 4df84af..b59ddb0 100644 --- a/config.go +++ b/config.go @@ -22,8 +22,13 @@ type AppConfig struct { var Config AppConfig func readConfig() error { - log.Printf("Read configration from config.json") - body, err := ioutil.ReadFile("config.json") + return readConfigFile("config.json") +} + +func readConfigFile(file string) error { + + log.Printf("Read configration from %s", file) + body, err := ioutil.ReadFile(file) if err != nil { log.Fatal("Fatal error Cannot read config ..") return err @@ -42,3 +47,7 @@ func readConfig() error { fmt.Println(string(j)) return err } + +func readConfigForTest() error { + return readConfigFile("config.test.json") +} diff --git a/config.test.json b/config.test.json new file mode 100644 index 0000000..166eeb9 --- /dev/null +++ b/config.test.json @@ -0,0 +1,11 @@ +{ + "Rpn": { + "Url" : "https://deposit.paylomo.net/pay.php?r=payEasy", + "UrlTest" : "https://deposit-mac.chinapaytech.com/pay.php?r=payEasy", + "MD5P2P" : "370296119874502", + "MD5FAT" : "207841502473198" + }, + "LeanWork" :{ + "MD5Key" : "492815086935204" + } +} \ No newline at end of file diff --git a/main_test.go b/main_test.go new file mode 100644 index 0000000..b57d7f2 --- /dev/null +++ b/main_test.go @@ -0,0 +1,12 @@ +package main + +import ( + "os" + "testing" +) + +func TestMain(m *testing.M) { + // call flag.Parse() here if TestMain uses flags + readConfigForTest() + os.Exit(m.Run()) +}