Skip to content

Commit

Permalink
fix for ci
Browse files Browse the repository at this point in the history
Signed-off-by: Kosuke Morimoto <kou.morimoto@gmail.com>
  • Loading branch information
kmrmt committed Aug 6, 2020
1 parent 360e3ff commit 0985a92
Show file tree
Hide file tree
Showing 6 changed files with 1,441 additions and 47 deletions.
133 changes: 133 additions & 0 deletions pkg/tools/cli/loadtest/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,136 @@ func TestNewConfig(t *testing.T) {
})
}
}

func TestServiceMethod(t *testing.T) {
type args struct {
s string
}
type want struct {
want Service
}
type test struct {
name string
args args
want want
checkFunc func(want, Service) error
beforeFunc func(args)
afterFunc func(args)
}
defaultCheckFunc := func(w want, got Service) error {
if !reflect.DeepEqual(got, w.want) {
return errors.Errorf("got = %v, want %v", got, w.want)
}
return nil
}
tests := []test{
// TODO test cases
/*
{
name: "test_case_1",
args: args {
s: "",
},
want: want{},
checkFunc: defaultCheckFunc,
},
*/

// TODO test cases
/*
func() test {
return test {
name: "test_case_2",
args: args {
s: "",
},
want: want{},
checkFunc: defaultCheckFunc,
}
}(),
*/
}

for _, test := range tests {
t.Run(test.name, func(tt *testing.T) {
defer goleak.VerifyNone(tt)
if test.beforeFunc != nil {
test.beforeFunc(test.args)
}
if test.afterFunc != nil {
defer test.afterFunc(test.args)
}
if test.checkFunc == nil {
test.checkFunc = defaultCheckFunc
}

got := ServiceMethod(test.args.s)
if err := test.checkFunc(test.want, got); err != nil {
tt.Errorf("error = %v", err)
}

})
}
}

func TestService_String(t *testing.T) {
type want struct {
want string
}
type test struct {
name string
s Service
want want
checkFunc func(want, string) error
beforeFunc func()
afterFunc func()
}
defaultCheckFunc := func(w want, got string) error {
if !reflect.DeepEqual(got, w.want) {
return errors.Errorf("got = %v, want %v", got, w.want)
}
return nil
}
tests := []test{
// TODO test cases
/*
{
name: "test_case_1",
want: want{},
checkFunc: defaultCheckFunc,
},
*/

// TODO test cases
/*
func() test {
return test {
name: "test_case_2",
want: want{},
checkFunc: defaultCheckFunc,
}
}(),
*/
}

for _, test := range tests {
t.Run(test.name, func(tt *testing.T) {
defer goleak.VerifyNone(tt)
if test.beforeFunc != nil {
test.beforeFunc()
}
if test.afterFunc != nil {
defer test.afterFunc()
}
if test.checkFunc == nil {
test.checkFunc = defaultCheckFunc
}

got := test.s.String()
if err := test.checkFunc(test.want, got); err != nil {
tt.Errorf("error = %v", err)
}

})
}
}
Loading

0 comments on commit 0985a92

Please sign in to comment.