github.com/ixpectus/declarate@v0.0.0-20240422152255-708027d7c068/run/wrap.go (about) 1 package run 2 3 import ( 4 "github.com/ixpectus/declarate/contract" 5 ) 6 7 func (r *Runner) beforeTestStep(file string, conf *runConfig, lvl int) { 8 if r.config.Wrapper != nil { 9 cfg := &contract.RunConfig{ 10 Name: conf.Name, 11 Vars: r.currentVars, 12 Variables: conf.Variables, 13 Commands: conf.Commands, 14 } 15 r.config.Wrapper.BeforeTestStep(file, cfg, lvl) 16 conf.Commands = cfg.Commands 17 } 18 } 19 20 func (r *Runner) afterTestStep(file string, conf *runConfig, result Result, polling bool) { 21 if r.config.Wrapper != nil { 22 cfg := &contract.RunConfig{ 23 Name: conf.Name, 24 Vars: r.currentVars, 25 Variables: conf.Variables, 26 Commands: conf.Commands, 27 } 28 r.config.Wrapper.AfterTestStep(cfg, 29 contract.Result{ 30 Err: result.Err, 31 Name: conf.Name, 32 Lvl: result.Lvl, 33 FileName: file, 34 Response: result.Response, 35 }, 36 polling, 37 ) 38 conf.Commands = cfg.Commands 39 } 40 } 41 42 func (r *Runner) beforeTest(file string, conf *runConfig, lvl int) { 43 if r.config.Wrapper != nil { 44 cfg := &contract.RunConfig{ 45 Name: conf.Name, 46 Vars: r.currentVars, 47 Variables: conf.Variables, 48 Commands: conf.Commands, 49 } 50 r.config.Wrapper.BeforeTest(file, cfg, lvl) 51 conf.Commands = cfg.Commands 52 } 53 } 54 55 func (r *Runner) afterTest(file string, conf runConfig, result Result) { 56 if r.config.Wrapper != nil { 57 cfg := &contract.RunConfig{ 58 Name: conf.Name, 59 Vars: r.currentVars, 60 Variables: conf.Variables, 61 Commands: conf.Commands, 62 } 63 r.config.Wrapper.AfterTest(cfg, 64 contract.Result{ 65 Err: result.Err, 66 Name: conf.Name, 67 Lvl: result.Lvl, 68 FileName: file, 69 Response: result.Response, 70 PollResult: result.PollResult, 71 }, 72 ) 73 conf.Commands = cfg.Commands 74 } 75 }