当前位置: 首页>>代码示例>>Golang>>正文


Golang config.SetCgrConfig函数代码示例

本文整理汇总了Golang中github.com/cgrates/cgrates/config.SetCgrConfig函数的典型用法代码示例。如果您正苦于以下问题:Golang SetCgrConfig函数的具体用法?Golang SetCgrConfig怎么用?Golang SetCgrConfig使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了SetCgrConfig函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: TestParseFsHangup

func TestParseFsHangup(t *testing.T) {
	cfg, _ := config.NewDefaultCGRConfig()
	config.SetCgrConfig(cfg)
	ev := new(FSEvent).AsEvent(hangupEv)
	setupTime, _ := ev.GetSetupTime(utils.META_DEFAULT, "")
	answerTime, _ := ev.GetAnswerTime(utils.META_DEFAULT, "")
	dur, _ := ev.GetDuration(utils.META_DEFAULT)
	if ev.GetReqType(utils.META_DEFAULT) != utils.META_PREPAID ||
		ev.GetDirection(utils.META_DEFAULT) != "*out" ||
		ev.GetTenant(utils.META_DEFAULT) != "cgrates.org" ||
		ev.GetCategory(utils.META_DEFAULT) != "call" ||
		ev.GetAccount(utils.META_DEFAULT) != "1001" ||
		ev.GetSubject(utils.META_DEFAULT) != "1001" ||
		ev.GetDestination(utils.META_DEFAULT) != "1003" ||
		setupTime.UTC() != time.Date(2015, 7, 7, 14, 52, 8, 0, time.UTC) ||
		answerTime.UTC() != time.Date(2015, 7, 7, 14, 52, 8, 0, time.UTC) ||
		dur != time.Duration(66)*time.Second ||
		ev.GetSupplier(utils.META_DEFAULT) != "supplier1" ||
		ev.GetDisconnectCause(utils.META_DEFAULT) != "NORMAL_CLEARING" {
		t.Error("Default values not matching",
			ev.GetReqType(utils.META_DEFAULT) != utils.META_PREPAID,
			ev.GetDirection(utils.META_DEFAULT) != "*out",
			ev.GetTenant(utils.META_DEFAULT) != "cgrates.org",
			ev.GetCategory(utils.META_DEFAULT) != "call",
			ev.GetAccount(utils.META_DEFAULT) != "1001",
			ev.GetSubject(utils.META_DEFAULT) != "1001",
			ev.GetDestination(utils.META_DEFAULT) != "1003",
			setupTime.UTC() != time.Date(2015, 7, 7, 14, 52, 8, 0, time.UTC),
			answerTime.UTC() != time.Date(2015, 7, 7, 14, 52, 8, 0, time.UTC),
			dur != time.Duration(66)*time.Second,
			ev.GetSupplier(utils.META_DEFAULT) != "supplier1",
			ev.GetDisconnectCause(utils.META_DEFAULT) != "NORMAL_CLEARING")
	}
}
开发者ID:bhepp,项目名称:cgrates,代码行数:34,代码来源:fsevent_test.go

示例2: TestParseFsHangup

func TestParseFsHangup(t *testing.T) {
	cfg, _ = config.NewDefaultCGRConfig()
	config.SetCgrConfig(cfg)
	ev := new(FSEvent).New(hangupEv)
	setupTime, _ := ev.GetSetupTime(utils.META_DEFAULT)
	answerTime, _ := ev.GetAnswerTime(utils.META_DEFAULT)
	dur, _ := ev.GetDuration(utils.META_DEFAULT)
	if ev.GetReqType(utils.META_DEFAULT) != utils.PSEUDOPREPAID ||
		ev.GetDirection(utils.META_DEFAULT) != "*out" ||
		ev.GetTenant(utils.META_DEFAULT) != "cgrates.org" ||
		ev.GetCategory(utils.META_DEFAULT) != "call" ||
		ev.GetAccount(utils.META_DEFAULT) != "1003" ||
		ev.GetSubject(utils.META_DEFAULT) != "1003" ||
		ev.GetDestination(utils.META_DEFAULT) != "1002" ||
		setupTime.UTC() != time.Date(2014, 4, 25, 16, 8, 27, 0, time.UTC) ||
		answerTime.UTC() != time.Date(2014, 4, 25, 16, 8, 40, 0, time.UTC) ||
		dur != time.Duration(5)*time.Second {
		t.Error("Default values not matching",
			ev.GetReqType(utils.META_DEFAULT) != utils.PSEUDOPREPAID,
			ev.GetDirection(utils.META_DEFAULT) != "*out",
			ev.GetTenant(utils.META_DEFAULT) != "cgrates.org",
			ev.GetCategory(utils.META_DEFAULT) != "call",
			ev.GetAccount(utils.META_DEFAULT) != "1003",
			ev.GetSubject(utils.META_DEFAULT) != "1003",
			ev.GetDestination(utils.META_DEFAULT) != "1002",
			setupTime.UTC() != time.Date(2014, 4, 25, 17, 8, 27, 0, time.UTC),
			answerTime.UTC() != time.Date(2014, 4, 25, 17, 8, 40, 0, time.UTC),
			dur != time.Duration(5)*time.Second)
	}
}
开发者ID:intralanman,项目名称:cgrates,代码行数:30,代码来源:fsevent_test.go

示例3: TestFsEvGetExtraFields

func TestFsEvGetExtraFields(t *testing.T) {
	cfg, _ := config.NewDefaultCGRConfig()
	cfg.SmFsConfig.ExtraFields = []*utils.RSRField{&utils.RSRField{Id: "Channel-Read-Codec-Name"}, &utils.RSRField{Id: "Channel-Write-Codec-Name"}, &utils.RSRField{Id: "NonExistingHeader"}}
	config.SetCgrConfig(cfg)
	ev := new(FSEvent).AsEvent(hangupEv)
	expectedExtraFields := map[string]string{"Channel-Read-Codec-Name": "SPEEX", "Channel-Write-Codec-Name": "SPEEX", "NonExistingHeader": ""}
	if extraFields := ev.GetExtraFields(); !reflect.DeepEqual(expectedExtraFields, extraFields) {
		t.Errorf("Expecting: %+v, received: %+v", expectedExtraFields, extraFields)
	}
}
开发者ID:bhepp,项目名称:cgrates,代码行数:10,代码来源:fsevent_test.go

示例4: TestAuthSetStorage

func TestAuthSetStorage(t *testing.T) {
	ratingDbAuth, _ = engine.NewMapStorageJson()
	engine.SetRatingStorage(ratingDbAuth)
	acntDbAuth, _ = engine.NewMapStorageJson()
	engine.SetAccountingStorage(acntDbAuth)
	cfg, _ := config.NewDefaultCGRConfig()
	config.SetCgrConfig(cfg)
	rsponder = new(engine.Responder)

}
开发者ID:kevinlovesing,项目名称:cgrates,代码行数:10,代码来源:auth_test.go

示例5: TestTutOsipsCallsInitCfg

func TestTutOsipsCallsInitCfg(t *testing.T) {
	// Init config first
	var err error
	tutOsipsCallsCfg, err = config.NewCGRConfigFromFolder(path.Join(*dataDir, "tutorials", "osips_async", "cgrates", "etc", "cgrates"))
	if err != nil {
		t.Error(err)
	}
	tutOsipsCallsCfg.DataFolderPath = *dataDir // Share DataFolderPath through config towards StoreDb for Flush()
	config.SetCgrConfig(tutOsipsCallsCfg)
}
开发者ID:cgrates,项目名称:cgrates,代码行数:10,代码来源:tutorial_osips_calls_test.go

示例6: TestTutSMGInitCfg

func TestTutSMGInitCfg(t *testing.T) {
	tutSMGCfgPath = path.Join(*dataDir, "conf", "samples", "smgeneric")
	// Init config first
	var err error
	tutSMGCfg, err = config.NewCGRConfigFromFolder(tutSMGCfgPath)
	if err != nil {
		t.Error(err)
	}
	tutSMGCfg.DataFolderPath = *dataDir // Share DataFolderPath through config towards StoreDb for Flush()
	config.SetCgrConfig(tutSMGCfg)
}
开发者ID:cgrates,项目名称:cgrates,代码行数:11,代码来源:tut_smgeneric_it_test.go

示例7: TestActionsitInitCfg

func TestActionsitInitCfg(t *testing.T) {

	// Init config first
	var err error
	actsLclCfg, err = config.NewCGRConfigFromFolder(actsLclCfgPath)
	if err != nil {
		t.Error(err)
	}
	actsLclCfg.DataFolderPath = *dataDir // Share DataFolderPath through config towards StoreDb for Flush()
	config.SetCgrConfig(actsLclCfg)
}
开发者ID:cgrates,项目名称:cgrates,代码行数:11,代码来源:actions_it_test.go

示例8: TestDmtAgentInitCfg

func TestDmtAgentInitCfg(t *testing.T) {
	daCfgPath = path.Join(*dataDir, "conf", "samples", "dmtagent")
	// Init config first
	var err error
	daCfg, err = config.NewCGRConfigFromFolder(daCfgPath)
	if err != nil {
		t.Error(err)
	}
	daCfg.DataFolderPath = *dataDir // Share DataFolderPath through config towards StoreDb for Flush()
	config.SetCgrConfig(daCfg)
	rplyTimeout, _ = utils.ParseDurationWithSecs(*replyTimeout)
}
开发者ID:cgrates,项目名称:cgrates,代码行数:12,代码来源:dmtagent_it_test.go

示例9: TestTutAstCallsInitCfg

func TestTutAstCallsInitCfg(t *testing.T) {
	if !*testCalls {
		return
	}
	// Init config first
	var err error
	tutAstCallsCfg, err = config.NewCGRConfigFromFolder(path.Join(*dataDir, "tutorials", "asterisk_events", "cgrates", "etc", "cgrates"))
	if err != nil {
		t.Error(err)
	}
	tutAstCallsCfg.DataFolderPath = *dataDir // Share DataFolderPath through config towards StoreDb for Flush()
	config.SetCgrConfig(tutAstCallsCfg)
}
开发者ID:eloycoto,项目名称:cgrates,代码行数:13,代码来源:tutorial_astevents_calls_test.go

示例10: TestSMGRplcInitCfg

func TestSMGRplcInitCfg(t *testing.T) {

	smgRplcMasterCfgPath = path.Join(*dataDir, "conf", "samples", "smgreplcmaster")
	if smgRplcMasterCfg, err = config.NewCGRConfigFromFolder(smgRplcMasterCfgPath); err != nil {
		t.Fatal(err)
	}
	smgRplcMasterCfg.DataFolderPath = *dataDir // Share DataFolderPath through config towards StoreDb for Flush()
	config.SetCgrConfig(smgRplcMasterCfg)
	smgRplcSlaveCfgPath = path.Join(*dataDir, "conf", "samples", "smgreplcslave")
	if smgRplcSlaveCfg, err = config.NewCGRConfigFromFolder(smgRplcSlaveCfgPath); err != nil {
		t.Fatal(err)
	}
}
开发者ID:cgrates,项目名称:cgrates,代码行数:13,代码来源:smgreplc_it_test.go

示例11: init

func init() {
	if !*testLocal {
		return
	}
	tutCfgPath = path.Join(*dataDir, "conf", "samples", "tutorial_local_test.cfg")
	var err error
	tutCfg, err = config.NewCGRConfigFromFile(&tutCfgPath)
	if err != nil {
		log.Print("ERROR: ", err)
	}
	tutCfg.DataFolderPath = *dataDir // Share DataFolderPath through config towards StoreDb for Flush()
	config.SetCgrConfig(tutCfg)
}
开发者ID:intralanman,项目名称:cgrates,代码行数:13,代码来源:tutorial_local_test.go

示例12: TestOsipsEventGetValues

func TestOsipsEventGetValues(t *testing.T) {
	cfg, _ := config.NewDefaultCGRConfig()
	config.SetCgrConfig(cfg)
	setupTime, _ := osipsEv.GetSetupTime(utils.META_DEFAULT, "")
	eSetupTime, _ := utils.ParseTimeDetectLayout("1406370492", "")
	answerTime, _ := osipsEv.GetAnswerTime(utils.META_DEFAULT, "")
	eAnswerTime, _ := utils.ParseTimeDetectLayout("1406370499", "")
	dur, _ := osipsEv.GetDuration(utils.META_DEFAULT)
	pdd, _ := osipsEv.GetPdd(utils.META_DEFAULT)
	endTime, _ := osipsEv.GetEndTime(utils.META_DEFAULT, "")
	if osipsEv.GetName() != "E_ACC_CDR" ||
		osipsEv.GetCgrId("") != utils.Sha1("ODVkMDI2Mzc2MDY5N2EzODhjNTAzNTdlODhiZjRlYWQ", setupTime.UTC().String()) ||
		osipsEv.GetUUID() != "ODVkMDI2Mzc2MDY5N2EzODhjNTAzNTdlODhiZjRlYWQ" ||
		osipsEv.GetDirection(utils.META_DEFAULT) != utils.OUT ||
		osipsEv.GetSubject(utils.META_DEFAULT) != "dan" ||
		osipsEv.GetAccount(utils.META_DEFAULT) != "dan" ||
		osipsEv.GetDestination(utils.META_DEFAULT) != "+4986517174963" ||
		osipsEv.GetCallDestNr(utils.META_DEFAULT) != "+4986517174963" ||
		osipsEv.GetCategory(utils.META_DEFAULT) != cfg.DefaultCategory ||
		osipsEv.GetTenant(utils.META_DEFAULT) != "itsyscom.com" ||
		osipsEv.GetReqType(utils.META_DEFAULT) != utils.META_PREPAID ||
		!setupTime.Equal(eSetupTime) ||
		!answerTime.Equal(eAnswerTime) ||
		!endTime.Equal(eAnswerTime.Add(dur)) ||
		dur != time.Duration(20*time.Second) ||
		pdd != time.Duration(3)*time.Second ||
		osipsEv.GetSupplier(utils.META_DEFAULT) != "supplier3" ||
		osipsEv.GetDisconnectCause(utils.META_DEFAULT) != "200" ||
		osipsEv.GetOriginatorIP(utils.META_DEFAULT) != "172.16.254.77" {
		t.Error("GetValues not matching: ", osipsEv.GetName() != "E_ACC_CDR",
			osipsEv.GetCgrId("") != utils.Sha1("ODVkMDI2Mzc2MDY5N2EzODhjNTAzNTdlODhiZjRlYWQ", setupTime.UTC().String()),
			osipsEv.GetUUID() != "ODVkMDI2Mzc2MDY5N2EzODhjNTAzNTdlODhiZjRlYWQ",
			osipsEv.GetDirection(utils.META_DEFAULT) != utils.OUT,
			osipsEv.GetSubject(utils.META_DEFAULT) != "dan",
			osipsEv.GetAccount(utils.META_DEFAULT) != "dan",
			osipsEv.GetDestination(utils.META_DEFAULT) != "+4986517174963",
			osipsEv.GetCallDestNr(utils.META_DEFAULT) != "+4986517174963",
			osipsEv.GetCategory(utils.META_DEFAULT) != cfg.DefaultCategory,
			osipsEv.GetTenant(utils.META_DEFAULT) != "itsyscom.com",
			osipsEv.GetReqType(utils.META_DEFAULT) != utils.META_PREPAID,
			!setupTime.Equal(time.Date(2014, 7, 26, 12, 28, 12, 0, time.UTC)),
			!answerTime.Equal(time.Date(2014, 7, 26, 12, 28, 19, 0, time.Local)),
			!endTime.Equal(time.Date(2014, 7, 26, 12, 28, 39, 0, time.Local)),
			dur != time.Duration(20*time.Second),
			pdd != time.Duration(3)*time.Second,
			osipsEv.GetSupplier(utils.META_DEFAULT) != "supplier3",
			osipsEv.GetDisconnectCause(utils.META_DEFAULT) != "200",
			osipsEv.GetOriginatorIP(utils.META_DEFAULT) != "172.16.254.77",
		)
	}
}
开发者ID:kevinlovesing,项目名称:cgrates,代码行数:51,代码来源:osipsevent_test.go

示例13: TestEventSelectiveHeaders

// Test here if the answer is selected out of headers we specify, even if not default defined
func TestEventSelectiveHeaders(t *testing.T) {
	body := `Event-Name: RE_SCHEDULE
Core-UUID: 792e181c-b6e6-499c-82a1-52a778e7d82d
FreeSWITCH-Hostname: h1.ip-switch.net
FreeSWITCH-Switchname: h1.ip-switch.net
FreeSWITCH-IPv4: 88.198.12.156
FreeSWITCH-IPv6: %3A%3A1
Event-Date-Local: 2012-10-05%2013%3A41%3A38
Event-Date-GMT: Fri,%2005%20Oct%202012%2011%3A41%3A38%20GMT
Event-Date-Timestamp: 1349437298012866
Event-Calling-File: switch_scheduler.c
Event-Calling-Function: switch_scheduler_execute
Event-Calling-Line-Number: 65
Event-Sequence: 34263
Task-ID: 2
Task-Desc: heartbeat
Task-Group: core
Task-Runtime: 1349437318`
	cfg, _ := config.NewDefaultCGRConfig()
	config.SetCgrConfig(cfg)
	ev := new(FSEvent).AsEvent(body)
	setupTime, _ := ev.GetSetupTime("Event-Date-Local", "")
	answerTime, _ := ev.GetAnswerTime("Event-Date-Local", "")
	dur, _ := ev.GetDuration("Event-Calling-Line-Number")
	if ev.GetReqType("FreeSWITCH-Hostname") != "h1.ip-switch.net" ||
		ev.GetDirection("FreeSWITCH-Hostname") != "*out" ||
		ev.GetTenant("FreeSWITCH-Hostname") != "h1.ip-switch.net" ||
		ev.GetCategory("FreeSWITCH-Hostname") != "h1.ip-switch.net" ||
		ev.GetAccount("FreeSWITCH-Hostname") != "h1.ip-switch.net" ||
		ev.GetSubject("FreeSWITCH-Hostname") != "h1.ip-switch.net" ||
		ev.GetDestination("FreeSWITCH-Hostname") != "h1.ip-switch.net" ||
		setupTime != time.Date(2012, 10, 5, 13, 41, 38, 0, time.UTC) ||
		answerTime != time.Date(2012, 10, 5, 13, 41, 38, 0, time.UTC) ||
		dur != time.Duration(65)*time.Second ||
		ev.GetSupplier("FreeSWITCH-Hostname") != "h1.ip-switch.net" ||
		ev.GetDisconnectCause("FreeSWITCH-Hostname") != "h1.ip-switch.net" {
		t.Error("Values out of static not matching",
			ev.GetReqType("FreeSWITCH-Hostname") != "h1.ip-switch.net",
			ev.GetDirection("FreeSWITCH-Hostname") != "*out",
			ev.GetTenant("FreeSWITCH-Hostname") != "h1.ip-switch.net",
			ev.GetCategory("FreeSWITCH-Hostname") != "h1.ip-switch.net",
			ev.GetAccount("FreeSWITCH-Hostname") != "h1.ip-switch.net",
			ev.GetSubject("FreeSWITCH-Hostname") != "h1.ip-switch.net",
			ev.GetDestination("FreeSWITCH-Hostname") != "h1.ip-switch.net",
			setupTime != time.Date(2012, 10, 5, 13, 41, 38, 0, time.UTC),
			answerTime != time.Date(2012, 10, 5, 13, 41, 38, 0, time.UTC),
			dur != time.Duration(65)*time.Second,
			ev.GetSupplier("FreeSWITCH-Hostname") != "h1.ip-switch.net",
			ev.GetDisconnectCause("FreeSWITCH-Hostname") != "h1.ip-switch.net")
	}
}
开发者ID:bhepp,项目名称:cgrates,代码行数:52,代码来源:fsevent_test.go

示例14: TestSMGInitCfg

func TestSMGInitCfg(t *testing.T) {
	if !*testIntegration {
		return
	}
	daCfgPath = path.Join(*dataDir, "conf", "samples", "smg")
	// Init config first
	var err error
	daCfg, err = config.NewCGRConfigFromFolder(daCfgPath)
	if err != nil {
		t.Error(err)
	}
	daCfg.DataFolderPath = *dataDir // Share DataFolderPath through config towards StoreDb for Flush()
	config.SetCgrConfig(daCfg)
}
开发者ID:bhepp,项目名称:cgrates,代码行数:14,代码来源:smg_it_test.go

示例15: TestTutLocalInitCfg

func TestTutLocalInitCfg(t *testing.T) {
	if !*testLocal {
		return
	}
	tutLocalCfgPath = path.Join(*dataDir, "conf", "samples", "tutlocal")
	// Init config first
	var err error
	tutFsLocalCfg, err = config.NewCGRConfigFromFolder(tutLocalCfgPath)
	if err != nil {
		t.Error(err)
	}
	tutFsLocalCfg.DataFolderPath = *dataDir // Share DataFolderPath through config towards StoreDb for Flush()
	config.SetCgrConfig(tutFsLocalCfg)
}
开发者ID:nikbyte,项目名称:cgrates,代码行数:14,代码来源:tutorial_local_test.go


注:本文中的github.com/cgrates/cgrates/config.SetCgrConfig函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。