4
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2025-07-02 10:26:18 +00:00

Make config.Config more unit-test friendly (#586)

This commit is contained in:
Duco van Amstel
2018-11-13 22:30:56 +00:00
committed by Wim
parent e19ba5a06a
commit 16d5aeac7c
7 changed files with 190 additions and 72 deletions

View File

@ -2,27 +2,32 @@ package gateway
import (
"fmt"
"time"
"github.com/42wim/matterbridge/bridge"
"github.com/42wim/matterbridge/bridge/config"
samechannelgateway "github.com/42wim/matterbridge/gateway/samechannel"
// "github.com/davecgh/go-spew/spew"
"time"
)
type Router struct {
config.Config
Gateways map[string]*Gateway
Message chan config.Message
MattermostPlugin chan config.Message
*config.Config
}
func NewRouter(cfg *config.Config) (*Router, error) {
r := &Router{Message: make(chan config.Message), MattermostPlugin: make(chan config.Message), Gateways: make(map[string]*Gateway), Config: cfg}
func NewRouter(cfg config.Config) (*Router, error) {
r := &Router{
Config: cfg,
Message: make(chan config.Message),
MattermostPlugin: make(chan config.Message),
Gateways: make(map[string]*Gateway),
}
sgw := samechannelgateway.New(cfg)
gwconfigs := sgw.GetConfig()
for _, entry := range append(gwconfigs, cfg.Gateway...) {
for _, entry := range append(gwconfigs, cfg.ConfigValues().Gateway...) {
if !entry.Enable {
continue
}