Skip to content

Commit

Permalink
chore(test): Test_queryExecutor_QueryAllRecords
Browse files Browse the repository at this point in the history
  • Loading branch information
trakhimenok committed Aug 20, 2023
1 parent d3d1298 commit a264a6d
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion dal/query_executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ package dal

import (
"context"
"errors"
"fmt"
"github.com/stretchr/testify/assert"
"testing"
)

func TestNewSelector(t *testing.T) {
func TestNewQueryExecutor(t *testing.T) {
t.Run("panic_on_nil", func(t *testing.T) {
assert.Panics(t, func() {
NewQueryExecutor(nil)
Expand Down Expand Up @@ -85,3 +86,39 @@ func Test_selector_QueryAllRecords(t *testing.T) {
})
}
}

func Test_queryExecutor_QueryAllRecords(t *testing.T) {
type args struct {
c context.Context
query Query
}
tests := []struct {
name string
qe queryExecutor
args args
wantErr assert.ErrorAssertionFunc
}{
{
name: "returns_error",
qe: queryExecutor{
getReader: func(c context.Context, query Query) (reader Reader, err error) {
return nil, errors.New("test not implemented")
},
},
wantErr: func(t assert.TestingT, err error, i ...interface{}) bool {
return assert.NotNil(t, err, i...)
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := tt.qe.QueryAllRecords(tt.args.c, tt.args.query)
if !tt.wantErr(t, err, fmt.Sprintf("QueryReader(%v, %v)", tt.args.c, tt.args.query)) {
return
}
if err != nil {
assert.Nil(t, got)
}
})
}
}

0 comments on commit a264a6d

Please sign in to comment.