Kaynağa Gözat

config for test is separated and testMain is ready

tags/v0.5
patrick 5 yıl önce
ebeveyn
işleme
a2ec649a69
3 değiştirilmiş dosya ile 34 ekleme ve 2 silme
  1. +11
    -2
      config.go
  2. +11
    -0
      config.test.json
  3. +12
    -0
      main_test.go

+ 11
- 2
config.go Dosyayı Görüntüle

@@ -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")
}

+ 11
- 0
config.test.json Dosyayı Görüntüle

@@ -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"
}
}

+ 12
- 0
main_test.go Dosyayı Görüntüle

@@ -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())
}

Yükleniyor…
İptal
Kaydet