Ejemplo n.º 1
0
func TestLoadConfiguration(t *testing.T) {
	// Load app config
	_, err := configuration.LoadConfig()
	if err != nil {
		t.Errorf("loadDatabase does not pass. Configuration does not load, looking for %v, got %v", nil, err)
	}
}
Ejemplo n.º 2
0
func TestSetConfig(t *testing.T) {
	// Load app config
	Config, err := configuration.LoadConfig()
	if err != nil {
		t.Errorf("TestPush.SetConfig: %v", err)
	}
	// Set config in packages
	SetConfig(&Config)
}
Ejemplo n.º 3
0
func BenchmarkUpdateHoldingAccount(b *testing.B) {
	config, _ := configuration.LoadConfig()
	SetConfig(&config)

	for n := 0; n < b.N; n++ {
		ti := time.Now()
		sqlTime := int32(ti.Unix())
		_ = updateBankHoldingAccount(decimal.NewFromFloat(0.), sqlTime)
	}
}
Ejemplo n.º 4
0
func BenchmarkLoadDatabase(b *testing.B) {
	// Load app config
	Config, _ := configuration.LoadConfig()
	// Set config in packages
	SetConfig(&Config)

	for n := 0; n < b.N; n++ {
		_, _ = loadDatabase()
	}
}
Ejemplo n.º 5
0
func TestUpdateHoldingAccount(t *testing.T) {
	config, _ := configuration.LoadConfig()
	SetConfig(&config)

	ti := time.Now()
	sqlTime := int32(ti.Unix())

	err := updateBankHoldingAccount(decimal.NewFromFloat(0.), sqlTime)
	if err != nil {
		t.Errorf("DoUpdateHoldingAccount does not pass. Looking for %v, got %v", nil, err)
	}
}
Ejemplo n.º 6
0
func BenchmarkSavePainTransaction(b *testing.B) {
	config, _ := configuration.LoadConfig()
	SetConfig(&config)

	for n := 0; n < b.N; n++ {
		sender := AccountHolder{"accountNumSender", "bankNumSender"}
		receiver := AccountHolder{"accountNumReceiver", "bankNumReceiver"}
		trans := PAINTrans{101, sender, receiver, decimal.NewFromFloat(0.), decimal.NewFromFloat(0.)}

		_ = savePainTransaction(trans)
		_ = removePainTransaction(trans)
	}
}
Ejemplo n.º 7
0
func TestLoadDatabase(t *testing.T) {
	// Load app config
	Config, err := configuration.LoadConfig()
	if err != nil {
		t.Errorf("loadDatabase does not pass. Configuration does not load, looking for %v, got %v", nil, err)
	}
	// Set config in packages
	SetConfig(&Config)

	_, err = loadDatabase()

	if err != nil {
		t.Errorf("LoadDatabase does not pass. Looking for %v, got %v", nil, err)
	}
}
Ejemplo n.º 8
0
func TestSavePainTransaction(t *testing.T) {
	config, _ := configuration.LoadConfig()
	SetConfig(&config)

	sender := AccountHolder{"accountNumSender", "bankNumSender"}
	receiver := AccountHolder{"accountNumReceiver", "bankNumReceiver"}
	trans := PAINTrans{101, sender, receiver, decimal.NewFromFloat(0.), decimal.NewFromFloat(0.)}

	err := savePainTransaction(trans)
	if err != nil {
		t.Errorf("DoSavePainTransaction does not pass. Looking for %v, got %v", nil, err)
	}

	err = removePainTransaction(trans)
	if err != nil {
		t.Errorf("DoDeleteAccount does not pass. Looking for %v, got %v", nil, err)
	}
}
Ejemplo n.º 9
0
func RunHttpServer() (err error) {
	fmt.Println("HTTP Server called")

	// Load app config
	Config, err := configuration.LoadConfig()
	if err != nil {
		return errors.New("server.runServer: " + err.Error())
	}

	// Set config in packages
	accounts.SetConfig(&Config)
	payments.SetConfig(&Config)
	appauth.SetConfig(&Config)
	push.SetConfig(&Config)

	router := NewRouter()

	//err = http.ListenAndServeTLS(":8443", "certs/server.pem", "certs/server.key", router)
	err = http.ListenAndServeTLS(":8443", "certs/thebankoftoday.com.crt", "certs/thebankoftoday.com.key", router)
	fmt.Println(err)
	return
}