本文整理匯總了Golang中github.com/eris-ltd/eris-cli/testutils.IfExit函數的典型用法代碼示例。如果您正苦於以下問題:Golang IfExit函數的具體用法?Golang IfExit怎麽用?Golang IfExit使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了IfExit函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestRenameChain
func TestRenameChain(t *testing.T) {
aChain := "hichain"
rename1 := "niahctset"
rename2 := chainName
testNewChain(aChain)
defer testKillChain(t, rename2)
do := def.NowDo()
do.Name = aChain
do.NewName = rename1
logger.Infof("Renaming chain (from tests) =>\t%s:%s\n", do.Name, do.NewName)
if e := RenameChain(do); e != nil {
tests.IfExit(e)
}
testExistAndRun(t, rename1, true, true)
do = def.NowDo()
do.Name = rename1
do.NewName = rename2
logger.Infof("Renaming chain (from tests) =>\t%s:%s\n", do.Name, do.NewName)
if e := RenameChain(do); e != nil {
tests.IfExit(e)
}
testExistAndRun(t, chainName, true, true)
}
示例2: TestLoadServiceDefinition
func TestLoadServiceDefinition(t *testing.T) {
var e error
srv, e = loaders.LoadServiceDefinition(servName, true, 1)
if e != nil {
log.Error(e)
tests.IfExit(e)
}
if srv.Name != servName {
log.WithFields(log.Fields{
"expected": servName,
"got": srv.Name,
}).Error("Improper name on load")
}
if srv.Service.Name != servName {
log.WithFields(log.Fields{
"expected": servName,
"got": srv.Service.Name,
}).Error("Improper service name on load")
tests.IfExit(e)
}
if !srv.Service.AutoData {
log.Error("data_container not properly read on load")
tests.IfExit(e)
}
if srv.Operations.DataContainerName == "" {
log.Error("data_container_name not set")
tests.IfExit(e)
}
}
示例3: TestMain
func TestMain(m *testing.M) {
var logLevel log.LogLevel
logLevel = 0
// logLevel = 1
// logLevel = 3
log.SetLoggers(logLevel, os.Stdout, os.Stderr)
if os.Getenv("TEST_IN_CIRCLE") == "true" {
erisDir = os.Getenv("HOME")
}
file = path.Join(erisDir, "temp")
tests.IfExit(testsInit())
exitCode := m.Run()
if os.Getenv("TEST_IN_CIRCLE") != "true" {
testKillIPFS(nil)
tests.IfExit(tests.TestsTearDown())
}
os.Exit(exitCode)
}
示例4: TestRmChain
func TestRmChain(t *testing.T) {
testStartChain(t, chainName)
do := def.NowDo()
do.Operations.Args, do.Rm, do.RmD = []string{"keys"}, true, true
log.WithField("=>", do.Name).Info("Removing keys (from tests)")
if e := services.KillService(do); e != nil {
tests.IfExit(e)
}
do = def.NowDo()
do.Name, do.Rm, do.RmD = chainName, false, false
log.WithField("=>", do.Name).Info("Stopping chain (from tests)")
if e := KillChain(do); e != nil {
tests.IfExit(e)
}
testExistAndRun(t, chainName, true, false)
do = def.NowDo()
do.Name = chainName
do.RmD = true
log.WithField("=>", do.Name).Info("Removing chain (from tests)")
if e := RmChain(do); e != nil {
tests.IfExit(e)
}
testExistAndRun(t, chainName, false, false)
}
示例5: TestListKnownActions
func TestListKnownActions(t *testing.T) {
do := definitions.NowDo()
do.Known = true
do.Running = false
do.Existing = false
do.Operations.Args = []string{"testing"}
tests.IfExit(util.ListAll(do, "actions"))
k := strings.Split(do.Result, "\n") // tests output formatting.
if len(k) != 4 {
tests.IfExit(fmt.Errorf("Found %v action definition files, Expected 4. Something is wrong.\n", len(k)))
}
i := 0
for _, actFile := range k {
switch actFile {
case "do_not_use":
i++
case "chain_info":
i++
case "dns_register":
i++
case "keys_list":
i++
}
}
if i != 4 {
tests.IfExit(fmt.Errorf("Could not find all the expected action definition files.\n"))
}
}
示例6: TestMain
func TestMain(m *testing.M) {
log.SetFormatter(logger.ErisFormatter{})
log.SetLevel(log.ErrorLevel)
// log.SetLevel(log.InfoLevel)
// log.SetLevel(log.DebugLevel)
if os.Getenv("TEST_IN_CIRCLE") == "true" {
erisDir = os.Getenv("HOME")
}
// Prevent CLI from starting IPFS.
os.Setenv("ERIS_SKIP_ENSURE", "true")
file = filepath.Join(erisDir, "temp")
tests.IfExit(testsInit())
exitCode := m.Run()
if os.Getenv("TEST_IN_CIRCLE") != "true" {
tests.IfExit(tests.TestsTearDown())
}
os.Exit(exitCode)
}
示例7: TestKillRmService
func TestKillRmService(t *testing.T) {
testStartService(t, servName, false)
do := def.NowDo()
do.Name = servName
do.Rm = false
do.RmD = false
do.Operations.Args = []string{servName}
logger.Debugf("Stopping serv (via tests) =>\t%s\n", servName)
if e := KillService(do); e != nil {
logger.Errorln(e)
tests.IfExit(e)
}
testExistAndRun(t, servName, 1, true, false)
testNumbersExistAndRun(t, servName, 1, 0)
if os.Getenv("TEST_IN_CIRCLE") == "true" {
logger.Println("Testing in Circle. Where we don't have rm privileges (due to their driver). Skipping test.")
return
}
do = def.NowDo()
do.Name = servName
do.Operations.Args = []string{servName}
do.File = false
do.RmD = true
logger.Debugf("Removing serv (via tests) =>\t%s\n", servName)
if e := RmService(do); e != nil {
logger.Errorln(e)
tests.IfExit(e)
}
testExistAndRun(t, servName, 1, false, false)
testNumbersExistAndRun(t, servName, 0, 0)
}
示例8: TestNewService
func TestNewService(t *testing.T) {
do := def.NowDo()
servName := "keys"
do.Name = servName
do.Operations.Args = []string{"quay.io/eris/keys"}
log.WithFields(log.Fields{
"=>": do.Name,
"args": do.Operations.Args,
}).Debug("Creating a new service (from tests)")
e := NewService(do)
if e != nil {
log.Error(e)
tests.IfExit(e)
}
do = def.NowDo()
do.Operations.Args = []string{servName}
log.WithFields(log.Fields{
"container number": do.Operations.ContainerNumber,
"args": do.Operations.Args,
}).Debug("Starting service (from tests)")
e = StartService(do)
if e != nil {
log.Error(e)
tests.IfExit(e)
}
testExistAndRun(t, servName, 1, true, true)
testNumbersExistAndRun(t, servName, 1, 1)
testKillService(t, servName, true)
testExistAndRun(t, servName, 1, false, false)
}
示例9: TestRenameChain
func TestRenameChain(t *testing.T) {
aChain := "hichain"
rename1 := "niahctset"
rename2 := chainName
testNewChain(aChain)
defer testKillChain(t, rename2)
do := def.NowDo()
do.Name = aChain
do.NewName = rename1
log.WithFields(log.Fields{
"from": do.Name,
"to": do.NewName,
}).Info("Renaming chain (from tests)")
if e := RenameChain(do); e != nil {
tests.IfExit(e)
}
testExistAndRun(t, rename1, true, true)
do = def.NowDo()
do.Name = rename1
do.NewName = rename2
log.WithFields(log.Fields{
"from": do.Name,
"to": do.NewName,
}).Info("Renaming chain (from tests)")
if e := RenameChain(do); e != nil {
tests.IfExit(e)
}
testExistAndRun(t, chainName, true, true)
}
示例10: TestLoadServiceDefinition
func TestLoadServiceDefinition(t *testing.T) {
var e error
srv, e = loaders.LoadServiceDefinition(servName, true, 1)
if e != nil {
logger.Errorln(e)
tests.IfExit(e)
}
if srv.Name != servName {
logger.Errorf("FAILURE: improper name on LOAD. expected: %s\tgot: %s\n", servName, srv.Name)
}
if srv.Service.Name != servName {
logger.Errorf("FAILURE: improper service name on LOAD. expected: %s\tgot: %s\n", servName, srv.Service.Name)
tests.IfExit(e)
}
if !srv.Service.AutoData {
logger.Errorf("FAILURE: data_container not properly read on LOAD.\n")
tests.IfExit(e)
}
if srv.Operations.DataContainerName == "" {
logger.Errorf("FAILURE: data_container_name not set.\n")
tests.IfExit(e)
}
}
示例11: TestKillRmService
func TestKillRmService(t *testing.T) {
testStartService(t, servName, false)
do := def.NowDo()
do.Name = servName
do.Rm = false
do.RmD = false
do.Operations.Args = []string{servName}
log.WithField("=>", servName).Debug("Stopping service (from tests)")
if e := KillService(do); e != nil {
log.Error(e)
tests.IfExit(e)
}
testExistAndRun(t, servName, 1, true, false)
testNumbersExistAndRun(t, servName, 1, 0)
if os.Getenv("TEST_IN_CIRCLE") == "true" {
log.Warn("Testing in Circle where we don't have rm privileges. Skipping test")
return
}
do = def.NowDo()
do.Name = servName
do.Operations.Args = []string{servName}
do.File = false
do.RmD = true
log.WithField("=>", servName).Debug("Removing service (from tests)")
if e := RmService(do); e != nil {
log.Error(e)
tests.IfExit(e)
}
testExistAndRun(t, servName, 1, false, false)
testNumbersExistAndRun(t, servName, 0, 0)
}
示例12: TestInspectService
func TestInspectService(t *testing.T) {
testStartService(t, servName, false)
defer testKillService(t, servName, true)
do := def.NowDo()
do.Name = servName
do.Operations.Args = []string{"name"}
do.Operations.ContainerNumber = 1
log.WithFields(log.Fields{
"=>": fmt.Sprintf("%s:%d", servName, do.Operations.ContainerNumber),
"args": do.Operations.Args,
}).Debug("Inspect service (from tests)")
e := InspectService(do)
if e != nil {
log.Infof("Error inspecting service: %v", e)
tests.IfExit(e)
}
do = def.NowDo()
do.Name = servName
do.Operations.Args = []string{"config.user"}
do.Operations.ContainerNumber = 1
log.WithFields(log.Fields{
"=>": servName,
"args": do.Operations.Args,
}).Debug("Inspect service (from tests)")
e = InspectService(do)
if e != nil {
log.Infof("Error inspecting service: %v", e)
tests.IfExit(e)
}
}
示例13: TestInspectService
func TestInspectService(t *testing.T) {
testStartService(t, servName, false)
defer testKillService(t, servName, true)
do := def.NowDo()
do.Name = servName
do.Operations.Args = []string{"name"}
do.Operations.ContainerNumber = 1
logger.Debugf("Inspect service (via tests) =>\t%s:%v:%d\n", servName, do.Operations.Args, do.Operations.ContainerNumber)
e := InspectService(do)
if e != nil {
logger.Infof("Error inspecting service =>\t%v\n", e)
tests.IfExit(e)
}
do = def.NowDo()
do.Name = servName
do.Operations.Args = []string{"config.user"}
do.Operations.ContainerNumber = 1
logger.Debugf("Inspect service (via tests) =>\t%s:%v\n", servName, do.Operations.Args)
e = InspectService(do)
if e != nil {
logger.Infof("Error inspecting service =>\t%v\n", e)
tests.IfExit(e)
}
}
示例14: TestNewService
func TestNewService(t *testing.T) {
do := def.NowDo()
servName := "keys"
do.Name = servName
do.Operations.Args = []string{"quay.io/eris/keys"}
logger.Debugf("New-ing serv (via tests) =>\t%s:%v\n", do.Name, do.Operations.Args)
e := NewService(do)
if e != nil {
logger.Errorln(e)
tests.IfExit(e)
}
do = def.NowDo()
do.Operations.Args = []string{servName}
// do.Operations.ContainerNumber = util.AutoMagic(0, "service")
//do.Operations.ContainerNumber = 1
logger.Debugf("Starting serv (via tests) =>\t%v:%d\n", do.Operations.Args, do.Operations.ContainerNumber)
e = StartService(do)
if e != nil {
logger.Errorln(e)
tests.IfExit(e)
}
testExistAndRun(t, servName, 1, true, true)
testNumbersExistAndRun(t, servName, 1, 1)
testKillService(t, servName, true)
testExistAndRun(t, servName, 1, false, false)
}
示例15: TestCatService
func TestCatService(t *testing.T) {
do := def.NowDo()
do.Name = "do_not_use"
if err := CatService(do); err != nil {
tests.IfExit(err)
}
if do.Result != ini.DefaultIpfs2() {
tests.IfExit(fmt.Errorf("Cat Service on keys does not match DefaultKeys. Got %s \n Expected %s", do.Result, ini.DefaultIpfs2()))
}
}