本文整理匯總了Golang中github.com/eris-ltd/eris-cli/Godeps/_workspace/src/github.com/Sirupsen/logrus.Error函數的典型用法代碼示例。如果您正苦於以下問題:Golang Error函數的具體用法?Golang Error怎麽用?Golang Error使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Error函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestRenameAction
func TestRenameAction(t *testing.T) {
testExist(t, newName, false)
testExist(t, oldName, true)
do := definitions.NowDo()
do.Name = oldName
do.NewName = newName
log.WithFields(log.Fields{
"from": do.Name,
"to": do.NewName,
}).Info("Renaming action (from tests)")
if err := RenameAction(do); err != nil {
log.Error(err)
t.Fail()
}
testExist(t, newName, true)
testExist(t, oldName, false)
do = definitions.NowDo()
do.Name = newName
do.NewName = oldName
log.WithFields(log.Fields{
"from": do.Name,
"to": do.NewName,
}).Info("Renaming action (from tests)")
if err := RenameAction(do); err != nil {
log.Error(err)
t.Fail()
}
testExist(t, newName, false)
testExist(t, oldName, true)
}
示例2: 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)
}
示例3: 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)
}
示例4: 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)
}
}
示例5: testCreateDataByImport
//creates a new data container w/ dir to be used by a test
//maybe give create opts? => paths, files, file contents, etc
func testCreateDataByImport(t *testing.T, name string) {
newDataDir := filepath.Join(common.DataContainersPath, name)
if err := os.MkdirAll(newDataDir, 0777); err != nil {
log.Error(err)
t.FailNow()
os.Exit(1)
}
f, err := os.Create(filepath.Join(newDataDir, "test"))
if err != nil {
log.Error(err)
t.FailNow()
os.Exit(1)
}
defer f.Close()
do := definitions.NowDo()
do.Name = name
do.Source = filepath.Join(common.DataContainersPath, do.Name)
do.Destination = common.ErisContainerRoot
do.Operations.ContainerNumber = 1
log.WithField("=>", do.Name).Info("Importing data (from tests)")
if err := ImportData(do); err != nil {
log.Error(err)
t.Fail()
}
testExist(t, name, true)
}
示例6: TestInspectData
func TestInspectData(t *testing.T) {
testCreateDataByImport(t, dataName)
defer testKillDataCont(t, dataName)
do := definitions.NowDo()
do.Name = dataName
do.Operations.Args = []string{"name"}
do.Operations.ContainerNumber = 1
log.WithFields(log.Fields{
"data container": do.Name,
"args": do.Operations.Args,
}).Info("Inspecting data (from tests)")
if err := InspectData(do); err != nil {
log.Error(err)
t.FailNow()
}
do = definitions.NowDo()
do.Name = dataName
do.Operations.Args = []string{"config.network_disabled"}
do.Operations.ContainerNumber = 1
log.WithFields(log.Fields{
"data container": do.Name,
"args": do.Operations.Args,
}).Info("Inspecting data (from tests)")
if err := InspectData(do); err != nil {
log.Error(err)
t.Fail()
}
}
示例7: IfExit
func IfExit(err error) {
if err != nil {
log.Error(err)
if err := TestsTearDown(); err != nil {
log.Error(err)
}
os.Exit(1)
}
}
示例8: ifExit
//copied from testutils
func ifExit(err error) {
if err != nil {
log.Error(err)
if err := testsTearDown(); err != nil {
log.Error(err)
}
// log.Flush()
os.Exit(1)
}
}
示例9: RmData
// TODO: skip errors flag
func RmData(do *definitions.Do) (err error) {
if len(do.Operations.Args) == 0 {
do.Operations.Args = []string{do.Name}
}
for _, name := range do.Operations.Args {
do.Name = name
if util.IsDataContainer(do.Name, do.Operations.ContainerNumber) {
log.WithField("=>", do.Name).Info("Removing data container")
srv := definitions.BlankServiceDefinition()
srv.Operations.SrvContainerName = util.ContainersName("data", do.Name, do.Operations.ContainerNumber)
if err = perform.DockerRemove(srv.Service, srv.Operations, false, do.Volumes); err != nil {
log.Errorf("Error removing %s: %v", do.Name, err)
return err
}
} else {
err = fmt.Errorf("I cannot find that data container for %s. Please check the data container name you sent me.", do.Name)
log.Error(err)
return err
}
if do.RmHF {
log.WithField("=>", do.Name).Warn("Removing host directory")
if err = os.RemoveAll(filepath.Join(DataContainersPath, do.Name)); err != nil {
return err
}
}
}
do.Result = "success"
return err
}
示例10: ifExit
func ifExit(err error) {
if err != nil {
log.Error(err)
testsTearDown()
os.Exit(1)
}
}
示例11: TestRemoveAction
func TestRemoveAction(t *testing.T) {
do := definitions.NowDo()
do.Operations.Args = strings.Fields(oldName)
do.File = true
if err := RmAction(do); err != nil {
log.Error(err)
t.Fail()
}
testExist(t, oldName, false)
}
示例12: TestDoAction
func TestDoAction(t *testing.T) {
do := definitions.NowDo()
do.Operations.Args = strings.Fields(actionName)
do.Quiet = true
log.WithField("args", do.Operations.Args).Info("Performing action (from tests)")
if err := Do(do); err != nil {
log.Error(err)
t.Fail()
}
}
示例13: TestNewAction
func TestNewAction(t *testing.T) {
do := definitions.NowDo()
do.Operations.Args = strings.Fields(oldName)
log.WithField("args", do.Operations.Args).Info("New action (from tests)")
if err := NewAction(do); err != nil {
log.Error(err)
t.Fail()
}
testExist(t, oldName, true)
}
示例14: testStartChain
func testStartChain(t *testing.T, chain string) {
do := def.NowDo()
do.Name = chain
do.Operations.ContainerNumber = 1
do.Operations.PublishAllPorts = true
log.WithField("=>", do.Name).Info("Starting chain (from tests)")
if e := StartChain(do); e != nil {
log.Error(e)
tests.IfExit(nil)
}
testExistAndRun(t, chain, true, true)
}
示例15: TestListDataContainers
func TestListDataContainers(t *testing.T) {
dataName1 := fmt.Sprintf("%s%s", dataName, "one")
dataName2 := fmt.Sprintf("%s%s", dataName, "two")
datas := make(map[string]bool)
datas[dataName] = true
datas[dataName1] = true
datas[dataName2] = true
testCreateDataByImport(t, dataName)
testCreateDataByImport(t, dataName1)
testCreateDataByImport(t, dataName2)
defer testKillDataCont(t, dataName)
defer testKillDataCont(t, dataName1)
defer testKillDataCont(t, dataName2)
do := definitions.NowDo()
do.Quiet = true
if err := list.ListDatas(do); err != nil {
log.Error(err)
t.FailNow()
}
output := strings.Split(do.Result, "\n")
i := 0
for _, out := range output {
if datas[util.TrimString(out)] == true {
i++
}
}
if i != 3 {
log.Error(fmt.Errorf("Expected 3 data containers, got (%v)\n", i))
t.Fail()
}
}