Skip to content

Commit 3b9b299

Browse files
authored
Error panic (#8)
* cov1: update to octocov-action@v4 * cov1: revert * error_panic: done
1 parent fd2ddda commit 3b9b299

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

Diff for: .github/workflows/coverage.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ jobs:
2525
- name: Run tests with coverage report output
2626
run: make coverage
2727

28-
- uses: k1LoW/octocov-action@v1
28+
- uses: k1LoW/octocov-action@v1

Diff for: CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.0.6] - 2024/05/23
9+
### Changed
10+
- Error function now panics on error
11+
12+
813
## [0.0.5] - 2024/05/22
914
### Added
1015
- MIT license

Diff for: go_sql_raw.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ type RawSqlType map[string]interface{}
1212

1313
func Error(err error) {
1414
if err != nil {
15-
log.Fatal(err)
15+
log.Panic(err)
1616
}
1717
}
1818

Diff for: tests/go_sql_raw_test.go

+15-1
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ package tests
22

33
import (
44
"database/sql"
5+
"errors"
56
"fmt"
67
_ "github.com/mattn/go-sqlite3"
78
"github.com/mysiar-org/go-sql-raw"
89
"github.com/stretchr/testify/assert"
910
"testing"
1011
)
1112

12-
func Test(t *testing.T) {
13+
func TestRows2Map(t *testing.T) {
1314
db := setupDb()
1415
rows, err := db.Query("SELECT * FROM album ORDER BY id")
1516
chkError(err)
@@ -33,6 +34,19 @@ func Test(t *testing.T) {
3334
}
3435
}
3536

37+
func TestError(t *testing.T) {
38+
39+
err := errors.New("Dummy error.")
40+
t.Run("panics", func(t *testing.T) {
41+
defer func() {
42+
if r := recover(); r == nil {
43+
t.Errorf("function should panic")
44+
}
45+
}()
46+
go_sql_raw.Error(err)
47+
})
48+
}
49+
3650
func setupDb() *sql.DB {
3751
const file string = "test.db?mode=memory"
3852
db, err := sql.Open("sqlite3", file)

0 commit comments

Comments
 (0)