github.com/turingchain2020/turingchain@v1.1.21/cmd/autotest/types/simpleCase.go (about) 1 // Copyright Turing Corp. 2018 All Rights Reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // Package types 定义autotest包基础结构体、接口、以及函数 6 package types 7 8 import ( 9 "errors" 10 "strings" 11 ) 12 13 //simple case just executes without checking, suitable for init situation 14 15 //SimpleCase 简单用例 16 type SimpleCase struct { 17 BaseCase 18 } 19 20 //SimplePack 简单pack 21 type SimplePack struct { 22 BaseCasePack 23 } 24 25 //SendCommand 发送cmd 26 func (testCase *SimpleCase) SendCommand(packID string) (PackFunc, error) { 27 28 output, err := RunTuringchainCli(strings.Fields(testCase.GetCmd())) 29 if err != nil { 30 return nil, errors.New(output) 31 } 32 testPack := &SimplePack{} 33 pack := testPack.GetBasePack() 34 pack.TxHash = output 35 pack.TCase = testCase 36 37 pack.PackID = packID 38 pack.CheckTimes = 0 39 return testPack, nil 40 41 } 42 43 //CheckResult simple case needn't check 44 func (pack *SimplePack) CheckResult(handlerMap interface{}) (bCheck bool, bSuccess bool) { 45 46 bCheck = true 47 bSuccess = true 48 if strings.Contains(pack.TxHash, "Err") || strings.Contains(pack.TxHash, "connection refused") { 49 50 bSuccess = false 51 } 52 53 return bCheck, bSuccess 54 }