1/* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16package mock 17 18import ( 19 "context" 20 "fotff/tester" 21 "github.com/sirupsen/logrus" 22) 23 24type Tester struct{} 25 26func NewTester() tester.Tester { 27 return &Tester{} 28} 29 30func (t *Tester) TaskName() string { 31 return "mock" 32} 33 34func (t *Tester) Prepare(pkgDir string, device string, ctx context.Context) error { 35 return nil 36} 37 38func (t *Tester) DoTestTask(device string, ctx context.Context) ([]tester.Result, error) { 39 logrus.Infof("TEST_001 pass") 40 logrus.Warnf("TEST_002 pass") 41 logrus.Warnf("TEST_003 pass") 42 return []tester.Result{ 43 {TestCaseName: "TEST_001", Status: tester.ResultPass}, 44 {TestCaseName: "TEST_002", Status: tester.ResultPass}, 45 {TestCaseName: "TEST_003", Status: tester.ResultPass}, 46 }, nil 47} 48 49func (t *Tester) DoTestCase(device string, testCase string, ctx context.Context) (tester.Result, error) { 50 logrus.Warnf("%s pass", testCase) 51 return tester.Result{TestCaseName: testCase, Status: tester.ResultPass}, nil 52} 53 54func (t *Tester) DoTestCases(device string, testcases []string, ctx context.Context) ([]tester.Result, error) { 55 var ret []tester.Result 56 for _, testcase := range testcases { 57 r, err := t.DoTestCase(device, testcase, ctx) 58 if err != nil { 59 return nil, err 60 } 61 ret = append(ret, r) 62 } 63 return ret, nil 64} 65