本文整理汇总了Golang中github.com/cgrates/cgrates/engine.NewStringCSVStorage函数的典型用法代码示例。如果您正苦于以下问题:Golang NewStringCSVStorage函数的具体用法?Golang NewStringCSVStorage怎么用?Golang NewStringCSVStorage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewStringCSVStorage函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestSMSLoadCsvTpSmsChrg1
func TestSMSLoadCsvTpSmsChrg1(t *testing.T) {
timings := `ALWAYS,*any,*any,*any,*any,00:00:00`
rates := `RT_SMS_5c,0,0.005,1,1,0`
destinationRates := `DR_SMS_1,*any,RT_SMS_5c,*up,4,0,`
ratingPlans := `RP_SMS1,DR_SMS_1,ALWAYS,10`
ratingProfiles := `*out,cgrates.org,sms,*any,2012-01-01T00:00:00Z,RP_SMS1,,`
csvr := engine.NewTpReader(ratingDb, acntDb, engine.NewStringCSVStorage(',', "", timings, rates, destinationRates, ratingPlans, ratingProfiles,
"", "", "", "", "", "", "", "", "", "", ""), "", "")
if err := csvr.LoadTimings(); err != nil {
t.Fatal(err)
}
if err := csvr.LoadRates(); err != nil {
t.Fatal(err)
}
if err := csvr.LoadDestinationRates(); err != nil {
t.Fatal(err)
}
if err := csvr.LoadRatingPlans(); err != nil {
t.Fatal(err)
}
if err := csvr.LoadRatingProfiles(); err != nil {
t.Fatal(err)
}
csvr.WriteToDatabase(false, false, false)
cache2go.Flush()
ratingDb.PreloadRatingCache()
acntDb.PreloadAccountingCache()
if cachedRPlans := cache2go.CountEntries(utils.RATING_PLAN_PREFIX); cachedRPlans != 1 {
t.Error("Wrong number of cached rating plans found", cachedRPlans)
}
if cachedRProfiles := cache2go.CountEntries(utils.RATING_PROFILE_PREFIX); cachedRProfiles != 0 {
t.Error("Wrong number of cached rating profiles found", cachedRProfiles)
}
}
开发者ID:eloycoto,项目名称:cgrates,代码行数:35,代码来源:smschrg1_test.go
示例2: TestCosts1LoadCsvTp
func TestCosts1LoadCsvTp(t *testing.T) {
timings := `ALWAYS,*any,*any,*any,*any,00:00:00
ASAP,*any,*any,*any,*any,*asap`
dests := `GERMANY,+49
GERMANY_MOBILE,+4915
GERMANY_MOBILE,+4916
GERMANY_MOBILE,+4917`
rates := `RT_1CENT,0,1,1s,1s,0s
RT_DATA_2c,0,0.002,10,10,0
RT_SMS_5c,0,0.005,1,1,0`
destinationRates := `DR_RETAIL,GERMANY,RT_1CENT,*up,4,0,
DR_RETAIL,GERMANY_MOBILE,RT_1CENT,*up,4,0,
DR_DATA_1,*any,RT_DATA_2c,*up,4,0,
DR_SMS_1,*any,RT_SMS_5c,*up,4,0,`
ratingPlans := `RP_RETAIL,DR_RETAIL,ALWAYS,10
RP_DATA1,DR_DATA_1,ALWAYS,10
RP_SMS1,DR_SMS_1,ALWAYS,10`
ratingProfiles := `*out,cgrates.org,call,*any,2012-01-01T00:00:00Z,RP_RETAIL,,
*out,cgrates.org,data,*any,2012-01-01T00:00:00Z,RP_DATA1,,
*out,cgrates.org,sms,*any,2012-01-01T00:00:00Z,RP_SMS1,,`
csvr := engine.NewTpReader(ratingDb, acntDb, engine.NewStringCSVStorage(',', dests, timings, rates, destinationRates, ratingPlans, ratingProfiles,
"", "", "", "", "", "", "", "", "", "", ""), "", "")
if err := csvr.LoadTimings(); err != nil {
t.Fatal(err)
}
if err := csvr.LoadDestinations(); err != nil {
t.Fatal(err)
}
if err := csvr.LoadRates(); err != nil {
t.Fatal(err)
}
if err := csvr.LoadDestinationRates(); err != nil {
t.Fatal(err)
}
if err := csvr.LoadRatingPlans(); err != nil {
t.Fatal(err)
}
if err := csvr.LoadRatingProfiles(); err != nil {
t.Fatal(err)
}
csvr.WriteToDatabase(false, false, false)
cache2go.Flush()
ratingDb.PreloadRatingCache()
acntDb.PreloadAccountingCache()
if cachedRPlans := cache2go.CountEntries(utils.RATING_PLAN_PREFIX); cachedRPlans != 3 {
t.Error("Wrong number of cached rating plans found", cachedRPlans)
}
if cachedRProfiles := cache2go.CountEntries(utils.RATING_PROFILE_PREFIX); cachedRProfiles != 0 {
t.Error("Wrong number of cached rating profiles found", cachedRProfiles)
}
}
开发者ID:eloycoto,项目名称:cgrates,代码行数:53,代码来源:costs1_test.go
示例3: TestAuthLoadCsv
func TestAuthLoadCsv(t *testing.T) {
timings := ``
destinations := `DST_GERMANY_LANDLINE,49`
rates := `RT_1CENTWITHCF,0.02,0.01,60s,60s,0s`
destinationRates := `DR_GERMANY,DST_GERMANY_LANDLINE,RT_1CENTWITHCF,*up,8,,
DR_ANY_1CNT,*any,RT_1CENTWITHCF,*up,8,,`
ratingPlans := `RP_1,DR_GERMANY,*any,10
RP_ANY,DR_ANY_1CNT,*any,10`
ratingProfiles := `*out,cgrates.org,call,testauthpostpaid1,2013-01-06T00:00:00Z,RP_1,,
*out,cgrates.org,call,testauthpostpaid2,2013-01-06T00:00:00Z,RP_1,*any,
*out,cgrates.org,call,*any,2013-01-06T00:00:00Z,RP_ANY,,`
sharedGroups := ``
lcrs := ``
actions := `TOPUP10_AC,*topup_reset,,,,*monetary,*out,,*any,,,*unlimited,,0,10,false,false,10`
actionPlans := `TOPUP10_AT,TOPUP10_AC,*asap,10`
actionTriggers := ``
accountActions := `cgrates.org,testauthpostpaid1,TOPUP10_AT,,,`
derivedCharges := ``
cdrStats := ``
users := ``
aliases := ``
resLimits := ``
csvr := engine.NewTpReader(ratingDbAuth, acntDbAuth, engine.NewStringCSVStorage(',', destinations, timings, rates, destinationRates, ratingPlans, ratingProfiles,
sharedGroups, lcrs, actions, actionPlans, actionTriggers, accountActions, derivedCharges, cdrStats, users, aliases, resLimits), "", "")
if err := csvr.LoadAll(); err != nil {
t.Fatal(err)
}
csvr.WriteToDatabase(false, false, false)
if acnt, err := acntDbAuth.GetAccount("cgrates.org:testauthpostpaid1"); err != nil {
t.Error(err)
} else if acnt == nil {
t.Error("No account saved")
}
cache.Flush()
ratingDbAuth.PreloadRatingCache()
acntDbAuth.PreloadAccountingCache()
if cachedDests := cache.CountEntries(utils.DESTINATION_PREFIX); cachedDests != 0 {
t.Error("Wrong number of cached destinations found", cachedDests)
}
if cachedRPlans := cache.CountEntries(utils.RATING_PLAN_PREFIX); cachedRPlans != 2 {
t.Error("Wrong number of cached rating plans found", cachedRPlans)
}
if cachedRProfiles := cache.CountEntries(utils.RATING_PROFILE_PREFIX); cachedRProfiles != 0 {
t.Error("Wrong number of cached rating profiles found", cachedRProfiles)
}
if cachedActions := cache.CountEntries(utils.ACTION_PREFIX); cachedActions != 0 {
t.Error("Wrong number of cached actions found", cachedActions)
}
}
开发者ID:rinor,项目名称:cgrates,代码行数:51,代码来源:auth_test.go
示例4: TestAcntActsLoadCsv
func TestAcntActsLoadCsv(t *testing.T) {
timings := `ASAP,*any,*any,*any,*any,*asap`
destinations := ``
rates := ``
destinationRates := ``
ratingPlans := ``
ratingProfiles := ``
sharedGroups := ``
lcrs := ``
actions := `TOPUP10_AC,*topup_reset,,,,*voice,*out,,*any,,,*unlimited,,10,10,false,false,10
DISABLE_ACNT,*disable_account,,,,,,,,,,,,,,false,false,10
ENABLE_ACNT,*enable_account,,,,,,,,,,,,,,false,false,10`
actionPlans := `TOPUP10_AT,TOPUP10_AC,ASAP,10`
actionTriggers := ``
accountActions := `cgrates.org,1,TOPUP10_AT,,,`
derivedCharges := ``
cdrStats := ``
users := ``
aliases := ``
resLimits := ``
csvr := engine.NewTpReader(ratingDbAcntActs, acntDbAcntActs, engine.NewStringCSVStorage(',', destinations, timings, rates, destinationRates, ratingPlans, ratingProfiles,
sharedGroups, lcrs, actions, actionPlans, actionTriggers, accountActions, derivedCharges, cdrStats, users, aliases, resLimits), "", "")
if err := csvr.LoadAll(); err != nil {
t.Fatal(err)
}
csvr.WriteToDatabase(false, false, false)
cache.Flush()
ratingDbAcntActs.PreloadRatingCache()
acntDbAcntActs.PreloadAccountingCache()
expectAcnt := &engine.Account{ID: "cgrates.org:1"}
if acnt, err := acntDbAcntActs.GetAccount("cgrates.org:1"); err != nil {
t.Error(err)
} else if acnt == nil {
t.Error("No account created")
} else if !reflect.DeepEqual(expectAcnt.ActionTriggers, acnt.ActionTriggers) {
t.Errorf("Expecting: %+v, received: %+v", expectAcnt, acnt)
}
}
开发者ID:rinor,项目名称:cgrates,代码行数:40,代码来源:acntacts_test.go
示例5: TestLoadCsvTpDtChrg1
func TestLoadCsvTpDtChrg1(t *testing.T) {
timings := `TM1,*any,*any,*any,*any,00:00:00
TM2,*any,*any,*any,*any,01:00:00`
rates := `RT_DATA_2c,0,0.002,10,10,0
RT_DATA_1c,0,0.001,10,10,0`
destinationRates := `DR_DATA_1,*any,RT_DATA_2c,*up,4,0,
DR_DATA_2,*any,RT_DATA_1c,*up,4,0,`
ratingPlans := `RP_DATA1,DR_DATA_1,TM1,10
RP_DATA1,DR_DATA_2,TM2,10`
ratingProfiles := `*out,cgrates.org,data,*any,2012-01-01T00:00:00Z,RP_DATA1,,`
csvr := engine.NewTpReader(ratingDb, acntDb, engine.NewStringCSVStorage(',', "", timings, rates, destinationRates, ratingPlans, ratingProfiles,
"", "", "", "", "", "", "", "", "", ""), "", "", 10)
if err := csvr.LoadTimings(); err != nil {
t.Fatal(err)
}
if err := csvr.LoadRates(); err != nil {
t.Fatal(err)
}
if err := csvr.LoadDestinationRates(); err != nil {
t.Fatal(err)
}
if err := csvr.LoadRatingPlans(); err != nil {
t.Fatal(err)
}
if err := csvr.LoadRatingProfiles(); err != nil {
t.Fatal(err)
}
csvr.WriteToDatabase(false, false)
ratingDb.CacheRatingAll()
acntDb.CacheAccountingAll()
if cachedRPlans := cache2go.CountEntries(utils.RATING_PLAN_PREFIX); cachedRPlans != 1 {
t.Error("Wrong number of cached rating plans found", cachedRPlans)
}
if cachedRProfiles := cache2go.CountEntries(utils.RATING_PROFILE_PREFIX); cachedRProfiles != 1 {
t.Error("Wrong number of cached rating profiles found", cachedRProfiles)
}
}
开发者ID:nikbyte,项目名称:cgrates,代码行数:38,代码来源:datachrg1_test.go
示例6: TestLoadCsvTp2
func TestLoadCsvTp2(t *testing.T) {
timings := `ALWAYS,*any,*any,*any,*any,00:00:00
ASAP,*any,*any,*any,*any,*asap`
destinations := `DST_UK_Mobile_BIG5,447596
DST_UK_Mobile_BIG5,447956`
rates := `RT_UK_Mobile_BIG5_PKG,0.01,0,20s,20s,0s
RT_UK_Mobile_BIG5,0.01,0.10,1s,1s,0s`
destinationRates := `DR_UK_Mobile_BIG5_PKG,DST_UK_Mobile_BIG5,RT_UK_Mobile_BIG5_PKG,*up,8,0,
DR_UK_Mobile_BIG5,DST_UK_Mobile_BIG5,RT_UK_Mobile_BIG5,*up,8,0,`
ratingPlans := `RP_UK_Mobile_BIG5_PKG,DR_UK_Mobile_BIG5_PKG,ALWAYS,10
RP_UK,DR_UK_Mobile_BIG5,ALWAYS,10`
ratingProfiles := `*out,cgrates.org,call,*any,2013-01-06T00:00:00Z,RP_UK,,
*out,cgrates.org,call,discounted_minutes,2013-01-06T00:00:00Z,RP_UK_Mobile_BIG5_PKG,,`
sharedGroups := ``
lcrs := ``
actions := `TOPUP10_AC,*topup_reset,,,,*monetary,*out,,*any,,,*unlimited,,0,10,false,false,10
TOPUP10_AC1,*topup_reset,,,,*voice,*out,,DST_UK_Mobile_BIG5,discounted_minutes,,*unlimited,,40,10,false,false,10`
actionPlans := `TOPUP10_AT,TOPUP10_AC,ASAP,10
TOPUP10_AT,TOPUP10_AC1,ASAP,10`
actionTriggers := ``
accountActions := `cgrates.org,12345,TOPUP10_AT,,,`
derivedCharges := ``
cdrStats := ``
users := ``
aliases := ``
csvr := engine.NewTpReader(ratingDb2, acntDb2, engine.NewStringCSVStorage(',', destinations, timings, rates, destinationRates, ratingPlans, ratingProfiles,
sharedGroups, lcrs, actions, actionPlans, actionTriggers, accountActions, derivedCharges, cdrStats, users, aliases), "", "", 10)
if err := csvr.LoadDestinations(); err != nil {
t.Fatal(err)
}
if err := csvr.LoadTimings(); err != nil {
t.Fatal(err)
}
if err := csvr.LoadRates(); err != nil {
t.Fatal(err)
}
if err := csvr.LoadDestinationRates(); err != nil {
t.Fatal(err)
}
if err := csvr.LoadRatingPlans(); err != nil {
t.Fatal(err)
}
if err := csvr.LoadRatingProfiles(); err != nil {
t.Fatal(err)
}
if err := csvr.LoadSharedGroups(); err != nil {
t.Fatal(err)
}
if err := csvr.LoadLCRs(); err != nil {
t.Fatal(err)
}
if err := csvr.LoadActions(); err != nil {
t.Fatal(err)
}
if err := csvr.LoadActionPlans(); err != nil {
t.Fatal(err)
}
if err := csvr.LoadActionTriggers(); err != nil {
t.Fatal(err)
}
if err := csvr.LoadAccountActions(); err != nil {
t.Fatal(err)
}
if err := csvr.LoadDerivedChargers(); err != nil {
t.Fatal(err)
}
csvr.WriteToDatabase(false, false)
if acnt, err := acntDb2.GetAccount("cgrates.org:12345"); err != nil {
t.Error(err)
} else if acnt == nil {
t.Error("No account saved")
}
ratingDb2.CacheRatingAll()
acntDb2.CacheAccountingAll()
if cachedDests := cache2go.CountEntries(utils.DESTINATION_PREFIX); cachedDests != 2 {
t.Error("Wrong number of cached destinations found", cachedDests)
}
if cachedRPlans := cache2go.CountEntries(utils.RATING_PLAN_PREFIX); cachedRPlans != 2 {
t.Error("Wrong number of cached rating plans found", cachedRPlans)
}
if cachedRProfiles := cache2go.CountEntries(utils.RATING_PROFILE_PREFIX); cachedRProfiles != 2 {
t.Error("Wrong number of cached rating profiles found", cachedRProfiles)
}
if cachedActions := cache2go.CountEntries(utils.ACTION_PREFIX); cachedActions != 2 {
t.Error("Wrong number of cached actions found", cachedActions)
}
}
开发者ID:bhepp,项目名称:cgrates,代码行数:88,代码来源:ddazmbl2_test.go
注:本文中的github.com/cgrates/cgrates/engine.NewStringCSVStorage函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论