Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
37 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package clickhouse | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func Test_Naive_Result(t *testing.T) { | ||
var result result | ||
if _, err := result.LastInsertId(); assert.Error(t, err) { | ||
if rows, err := result.RowsAffected(); assert.Error(t, err) { | ||
assert.Equal(t, int64(0), rows) | ||
} | ||
} | ||
} | ||
|
||
func Test_Naive_Exception(t *testing.T) { | ||
exception := Exception{ | ||
Code: 42, | ||
Message: "test", | ||
} | ||
if assert.Implements(t, (*error)(nil), &exception) { | ||
assert.Equal(t, fmt.Sprintf("code: %d, message: %s", exception.Code, exception.Message), exception.Error()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
package clickhouse | ||
|
||
import "errors" | ||
|
||
type result struct{} | ||
|
||
func (*result) LastInsertId() (int64, error) { return 0, nil } | ||
func (*result) RowsAffected() (int64, error) { return 0, nil } | ||
func (*result) LastInsertId() (int64, error) { return 0, errors.New("LastInsertId is not supported") } | ||
func (*result) RowsAffected() (int64, error) { return 0, errors.New("RowsAffected is not supported") } |