Skip to content

Commit

Permalink
fix: make change in capture response method to record tests (#106)
Browse files Browse the repository at this point in the history
Signed-off-by: re-Tick <jain.ritik.1001@gmail.com>

Signed-off-by: re-Tick <jain.ritik.1001@gmail.com>
  • Loading branch information
re-Tick authored Aug 18, 2022
1 parent 02725df commit 1c99aed
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 30 deletions.
8 changes: 6 additions & 2 deletions integrations/ksql/connBeginTx.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ func (t Tx) Commit() error {
case "test":
// don't run
case "capture":
err = t.Tx.Commit()
if t.Tx != nil {
err = t.Tx.Commit()
}
default:
return errors.New("integrations: Not in a valid sdk mode")
}
Expand Down Expand Up @@ -79,7 +81,9 @@ func (t Tx) Rollback() error {
case "test":
// don't run
case "capture":
err = t.Tx.Rollback()
if t.Tx != nil {
err = t.Tx.Rollback()
}
default:
return errors.New("integrations: Not in a valid sdk mode")
}
Expand Down
34 changes: 22 additions & 12 deletions integrations/ksql/connPrepareContext.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,17 @@ func (s Stmt) Exec(args []driver.Value) (driver.Result, error) {
case "test":
//don't call method
case "capture":
result, err = s.Stmt.Exec(args)
l, e := result.LastInsertId()
drResult.LastInserted = l
drResult.LError = e.Error()
ra, e := result.RowsAffected()
drResult.RowsAff = ra
drResult.RError = e.Error()
if s.Stmt != nil {
result, err = s.Stmt.Exec(args)
if result != nil {
l, e := result.LastInsertId()
drResult.LastInserted = l
drResult.LError = e.Error()
ra, e := result.RowsAffected()
drResult.RowsAff = ra
drResult.RError = e.Error()
}
}
default:
return nil, err
}
Expand Down Expand Up @@ -94,8 +98,10 @@ func (s Stmt) Query(args []driver.Value) (driver.Rows, error) {
case "test":
// don't run
case "capture":
rows, err = s.Stmt.Query(args)
drRows.Rows = rows
if s.Stmt != nil {
rows, err = s.Stmt.Query(args)
drRows.Rows = rows
}
default:
return nil, errors.New("integrations: Not in a valid sdk mode")
}
Expand Down Expand Up @@ -138,8 +144,10 @@ func (s Stmt) NumInput() int {
case "test":
// don't run
case "capture":
o := s.Stmt.NumInput()
output = &o
if s.Stmt != nil {
o := s.Stmt.NumInput()
output = &o
}
default:
return 0
}
Expand Down Expand Up @@ -171,7 +179,9 @@ func (s Stmt) Close() error {
case "test":
// don't run
case "capture":
err = s.Stmt.Close()
if s.Stmt != nil {
err = s.Stmt.Close()
}
default:
return errors.New("integrations: Not in a valid sdk mode")
}
Expand Down
24 changes: 13 additions & 11 deletions integrations/ksql/execerContext.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,19 @@ func (c Conn) ExecContext(ctx context.Context, query string, args []driver.Named
//don't call Find method
case "capture":
result, err = execerContext.ExecContext(ctx, query, args)
// calls LastInsertId to capture their outputs
li, e := result.LastInsertId()
driverResult.LastInserted = li
if e != nil {
driverResult.LError = e.Error()
}
// calls RowsAffected to capture their outputs
ra, e := result.RowsAffected()
driverResult.RowsAff = ra
if e != nil {
driverResult.RError = e.Error()
if result != nil {
// calls LastInsertId to capture their outputs
li, e := result.LastInsertId()
driverResult.LastInserted = li
if e != nil {
driverResult.LError = e.Error()
}
// calls RowsAffected to capture their outputs
ra, e := result.RowsAffected()
driverResult.RowsAff = ra
if e != nil {
driverResult.RError = e.Error()
}
}
default:
return result, err
Expand Down
16 changes: 11 additions & 5 deletions integrations/ksql/queryerContext.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ func (r Rows) Columns() []string {
case "test":
// don't run
case "capture":
o := r.Rows.Columns()
output = &o
if r.Rows != nil {
o := r.Rows.Columns()
output = &o
}
default:
return nil
}
Expand Down Expand Up @@ -80,7 +82,9 @@ func (r Rows) Close() error {
return nil
}
case "capture":
err = r.Rows.Close()
if r.Rows != nil {
err = r.Rows.Close()
}
default:
return errors.New("integrations: Not in a valid sdk mode")
}
Expand Down Expand Up @@ -237,8 +241,10 @@ func (r Rows) Next(dest []driver.Value) error {
case "test":
// don't run
case "capture":
err = r.Rows.Next(dest)
output.Value = dest
if r.Rows != nil {
err = r.Rows.Next(dest)
output.Value = dest
}
default:
return errors.New("integrations: Not in a valid sdk mode")
}
Expand Down

0 comments on commit 1c99aed

Please sign in to comment.