go.uber.org/cadence@v1.2.9/internal/test_helpers_test.go (about) 1 // Copyright (c) 2017-2021 Uber Technologies Inc. 2 // 3 // Permission is hereby granted, free of charge, to any person obtaining a copy 4 // of this software and associated documentation files (the "Software"), to deal 5 // in the Software without restriction, including without limitation the rights 6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 // copies of the Software, and to permit persons to whom the Software is 8 // furnished to do so, subject to the following conditions: 9 // 10 // The above copyright notice and this permission notice shall be included in 11 // all copies or substantial portions of the Software. 12 // 13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 // THE SOFTWARE. 20 21 package internal 22 23 import ( 24 "testing" 25 26 "github.com/golang/mock/gomock" 27 "go.uber.org/zap/zaptest" 28 ) 29 30 // A collection of cross-test helpers. 31 // When a function is not intended to be used outside a file / suite, consider an instance method or variable instead. 32 33 // Creates a new workflow environment with the correct logger / testing.T configured. 34 func newTestWorkflowEnv(t *testing.T) *TestWorkflowEnvironment { 35 s := WorkflowTestSuite{} 36 s.SetLogger(zaptest.NewLogger(t)) 37 // tally is not set since metrics are not noisy by default, and the test-instance 38 // is largely useless without access to the instance for snapshots. 39 env := s.NewTestWorkflowEnvironment() 40 env.Test(t) 41 return env 42 } 43 44 // this is the mock for yarpcCallOptions, as gomock requires the num of arguments to be the same. 45 // see getYarpcCallOptions for the default case. 46 func callOptions() []interface{} { 47 return []interface{}{ 48 gomock.Any(), // library version 49 gomock.Any(), // feature version 50 gomock.Any(), // client name 51 gomock.Any(), // feature flags 52 } 53 } 54 55 // this is the mock for yarpcCallOptions, as gomock requires the num of arguments to be the same. 56 // see getYarpcCallOptions for the default case. 57 func callOptionsWithIsolationGroupHeader() []interface{} { 58 return []interface{}{ 59 gomock.Any(), // library version 60 gomock.Any(), // feature version 61 gomock.Any(), // client name 62 gomock.Any(), // feature flags 63 gomock.Any(), // isolation group header 64 } 65 }