Skip to content

Commit

Permalink
Issue 72.dockter.1 (#74)
Browse files Browse the repository at this point in the history
* #72 Savepoint

* #72 Add null testcases

* #72 Add null testcases

* #72 Prepare for versioned release
  • Loading branch information
docktermj authored May 19, 2023
1 parent b436622 commit 6b8c979
Show file tree
Hide file tree
Showing 10 changed files with 123 additions and 23 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

-

## [0.6.3] - 2023-05-19

### Changed in 0.6.3

- Fixed error conversion
- Added `gosec` security testing
- Update dependencies
- github.com/senzing/go-observing v0.2.5
- github.com/stretchr/testify v1.8.3

## [0.6.2] - 2023-05-10

### Changed in 0.6.2
Expand Down
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ dependencies:
.PHONY: test
test:
@go test -v -p 1 ./...
# @go test -v ./.
# @go test -v ./g2api
# @go test -v ./g2config
# @go test -v ./g2configmgr
# @go test -v ./g2diagnostic
# @go test -v ./g2engine
# @go test -v ./g2error
# @go test -v ./g2product

# -----------------------------------------------------------------------------
# Utility targets
Expand Down
12 changes: 12 additions & 0 deletions g2api/g2api_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package g2api

import (
"testing"
)

// ----------------------------------------------------------------------------
// Test interface functions
// ----------------------------------------------------------------------------

func TestG2api_Null(test *testing.T) {
}
12 changes: 12 additions & 0 deletions g2config/g2config_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package g2config

import (
"testing"
)

// ----------------------------------------------------------------------------
// Test interface functions
// ----------------------------------------------------------------------------

func TestG2config_Null(test *testing.T) {
}
12 changes: 12 additions & 0 deletions g2configmgr/g2configmgr_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package g2configmgr

import (
"testing"
)

// ----------------------------------------------------------------------------
// Test interface functions
// ----------------------------------------------------------------------------

func TestG2configmgr_Null(test *testing.T) {
}
12 changes: 12 additions & 0 deletions g2diagnostic/g2diagnostic_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package g2diagnostic

import (
"testing"
)

// ----------------------------------------------------------------------------
// Test interface functions
// ----------------------------------------------------------------------------

func TestG2diagnostic_Null(test *testing.T) {
}
12 changes: 12 additions & 0 deletions g2engine/g2engine_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package g2engine

import (
"testing"
)

// ----------------------------------------------------------------------------
// Test interface functions
// ----------------------------------------------------------------------------

func TestG2engine_Null(test *testing.T) {
}
44 changes: 21 additions & 23 deletions g2error/g2error.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,30 +42,27 @@ func extractErrorTexts(messageErrors []interface{}, messageTexts []string) ([]st

newMessageTexts := []string{}
for _, messageError := range messageErrors {
errorMap, ok := messageError.(map[string]interface{})
if !ok {
continue
}
textStringFromErrorMap, ok := errorMap["text"].(string)
if ok {
newMessageTexts = append(newMessageTexts, textStringFromErrorMap)
continue
}
textMap, ok := errorMap["text"].(map[string]interface{})
if !ok {
continue
}
textString, ok := textMap["text"].(string)
if ok {
newMessageTexts = append(newMessageTexts, textString)
}
errorsInterface, ok := textMap["errors"].([]interface{})
if !ok {
continue
messageText := ""
switch typedMessageError := messageError.(type) {
case map[string]interface{}:
switch typedMessageErrorText := typedMessageError["text"].(type) {
case map[string]interface{}:
errorValue, ok := typedMessageErrorText["errors"].([]interface{})
if ok {
newMessageTexts, err = extractErrorTexts(errorValue, newMessageTexts)
if err != nil {
return append(messageTexts, newMessageTexts...), err
}
}
case string:
messageText = typedMessageErrorText
}
case string:
messageText = typedMessageError
}
newMessageTexts, err = extractErrorTexts(errorsInterface, newMessageTexts)
if err != nil {
continue

if len(messageText) > 0 {
newMessageTexts = append(newMessageTexts, messageText)
}
}
return append(messageTexts, newMessageTexts...), err
Expand Down Expand Up @@ -280,6 +277,7 @@ Input
- originalError: The error containing the message to be analyzed.
*/
func Convert(originalError error) error {

result := originalError
if result != nil {
extractedErrorNumber, err := extractErrorNumber(originalError.Error())
Expand Down
12 changes: 12 additions & 0 deletions g2error/g2error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,18 @@ var testCases = []struct {
expectedTypes: []G2ErrorTypeIds{G2Retryable, G2Configuration},
falseTypes: []G2ErrorTypeIds{G2ModuleEmptyMessage},
},
{
name: "g2error-0023",
senzingMessage: "0023E|Conflicting DATA_SOURCE values 'CUSTOMERS' and 'BOB'",
message: `{
"errors": ["0023E|Conflicting DATA_SOURCE values 'CUSTOMERS' and 'BOB'"],
}`,
expectedCode: 23,
expectedMessage: "Conflicting DATA_SOURCE values 'CUSTOMERS' and 'BOB'",
expectedType: G2UnrecoverableError{},
expectedTypes: []G2ErrorTypeIds{G2Unrecoverable},
falseTypes: []G2ErrorTypeIds{G2ModuleEmptyMessage},
},
{
name: "g2error-99906",
senzingMessage: "99906E|Test message",
Expand Down
12 changes: 12 additions & 0 deletions g2product/g2product_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package g2product

import (
"testing"
)

// ----------------------------------------------------------------------------
// Test interface functions
// ----------------------------------------------------------------------------

func TestG2product_Null(test *testing.T) {
}

0 comments on commit 6b8c979

Please sign in to comment.