diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index f162dd9..19b2237 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -25,4 +25,4 @@ jobs: - name: Run tests with coverage report output run: make coverage - - uses: k1LoW/octocov-action@v1 \ No newline at end of file + - uses: k1LoW/octocov-action@v1 diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b00b1f..d3b9c13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.0.6] - 2024/05/23 +### Changed +- Error function now panics on error + + ## [0.0.5] - 2024/05/22 ### Added - MIT license diff --git a/go_sql_raw.go b/go_sql_raw.go index 8734650..79e3cbe 100644 --- a/go_sql_raw.go +++ b/go_sql_raw.go @@ -12,7 +12,7 @@ type RawSqlType map[string]interface{} func Error(err error) { if err != nil { - log.Fatal(err) + log.Panic(err) } } diff --git a/tests/go_sql_raw_test.go b/tests/go_sql_raw_test.go index e0c2802..dc16b7b 100644 --- a/tests/go_sql_raw_test.go +++ b/tests/go_sql_raw_test.go @@ -2,6 +2,7 @@ package tests import ( "database/sql" + "errors" "fmt" _ "github.com/mattn/go-sqlite3" "github.com/mysiar-org/go-sql-raw" @@ -9,7 +10,7 @@ import ( "testing" ) -func Test(t *testing.T) { +func TestRows2Map(t *testing.T) { db := setupDb() rows, err := db.Query("SELECT * FROM album ORDER BY id") chkError(err) @@ -33,6 +34,19 @@ func Test(t *testing.T) { } } +func TestError(t *testing.T) { + + err := errors.New("Dummy error.") + t.Run("panics", func(t *testing.T) { + defer func() { + if r := recover(); r == nil { + t.Errorf("function should panic") + } + }() + go_sql_raw.Error(err) + }) +} + func setupDb() *sql.DB { const file string = "test.db?mode=memory" db, err := sql.Open("sqlite3", file)