Skip to content

Commit

Permalink
#232 Savepoint
Browse files Browse the repository at this point in the history
  • Loading branch information
docktermj committed Sep 10, 2024
1 parent 2c382b0 commit b044bde
Show file tree
Hide file tree
Showing 7 changed files with 638 additions and 112 deletions.
22 changes: 22 additions & 0 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,28 @@ Example:

```

## Debugging

### View SQLite

1. View the SQLite database.
Example:

```console
docker run \
--env SQLITE_DATABASE=G2C.db \
--interactive \
--name SqliteWeb \
--publish 9174:8080 \
--rm \
--tty \
--volume /tmp/sqlite:/data \
coleifer/sqlite-web

```

Visit [localhost:9174](http://localhost:9174).

## References

[clone-repository]: https://github.com/senzing-garage/knowledge-base/blob/main/HOWTO/clone-repository.md
Expand Down
3 changes: 2 additions & 1 deletion makefiles/linux.mk
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ setup-osarch-specific:

.PHONY: test-osarch-specific
test-osarch-specific:
@go test -json -v -p 1 ./... 2>&1 | tee /tmp/gotest.log | gotestfmt
# @go test -json -v -p 1 ./... 2>&1 | tee /tmp/gotest.log | gotestfmt
@go test -json -v -p 1 ./szengine 2>&1 | tee /tmp/gotest.log | gotestfmt

# -----------------------------------------------------------------------------
# Makefile targets supported only by this platform.
Expand Down
99 changes: 83 additions & 16 deletions szconfig/szconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,31 @@ import (
"github.com/stretchr/testify/require"
)

const (
dataSourceCode = "GO_TEST"
defaultTruncation = 76
instanceName = "SzConfig Test"
observerOrigin = "SzConfig observer"
printResults = false
verboseLogging = senzing.SzNoLogging
)

// Bad parameters

const (
badConfigDefinition = "}{"
badConfigHandle = uintptr(0)
badDataSourceCode = "\n\tGO_TEST"
badLogLevelName = "BadLogLevelName"
badSettings = "{]"
defaultTruncation = 76
instanceName = "SzConfig Test"
observerOrigin = "SzConfig observer"
printResults = false
verboseLogging = senzing.SzNoLogging
)

// Nil/empty parameters

var (
nilConfigDefinition string
nilConfigHandle uintptr
nilDataSourceCode string
)

var (
Expand All @@ -50,7 +64,6 @@ func TestSzconfig_AddDataSource(test *testing.T) {
szConfig := getTestObject(ctx, test)
configHandle, err := szConfig.CreateConfig(ctx)
require.NoError(test, err)
dataSourceCode := "GO_TEST"
actual, err := szConfig.AddDataSource(ctx, configHandle, dataSourceCode)
require.NoError(test, err)
printActual(test, actual)
Expand All @@ -69,7 +82,6 @@ func TestSzconfig_AddDataSource_withLoad(test *testing.T) {
require.NoError(test, err)
configHandle2, err := szConfig.ImportConfig(ctx, configDefinition)
require.NoError(test, err)
dataSourceCode := "GO_TEST"
actual, err := szConfig.AddDataSource(ctx, configHandle2, dataSourceCode)
require.NoError(test, err)
printActual(test, actual)
Expand All @@ -87,6 +99,24 @@ func TestSzconfig_AddDataSource_badDataSourceCode(test *testing.T) {
printActual(test, actual)
}

func TestSzconfig_AddDataSource_nilDataSourceCode(test *testing.T) {
ctx := context.TODO()
szConfig := getTestObject(ctx, test)
configHandle, err := szConfig.CreateConfig(ctx)
require.NoError(test, err)
actual, err := szConfig.AddDataSource(ctx, configHandle, nilDataSourceCode)
require.ErrorIs(test, err, szerror.ErrSzBadInput)
printActual(test, actual)
}

func TestSzconfig_AddDataSource_nilConfigHandle(test *testing.T) {
ctx := context.TODO()
szConfig := getTestObject(ctx, test)
actual, err := szConfig.AddDataSource(ctx, nilConfigHandle, dataSourceCode)
require.ErrorIs(test, err, szerror.ErrSz)
printActual(test, actual)
}

func TestSzconfig_CloseConfig(test *testing.T) {
ctx := context.TODO()
szConfig := getTestObject(ctx, test)
Expand All @@ -100,11 +130,15 @@ func TestSzconfig_CloseConfig_badConfigHandle(test *testing.T) {
ctx := context.TODO()
szConfig := getTestObject(ctx, test)
err := szConfig.CloseConfig(ctx, badConfigHandle)
require.ErrorIs(test, err, szerror.ErrSz) // TODO: Update to correct error once sz-sdk-go/szerror/ is updated.
require.ErrorIs(test, err, szerror.ErrSz)
}

// TODO: Implement TestSzconfig_CloseConfig_error
// func TestSzconfig_CloseConfig_error(test *testing.T) {}
func TestSzconfig_CloseConfig_nilConfigHandle(test *testing.T) {
ctx := context.TODO()
szConfig := getTestObject(ctx, test)
err := szConfig.CloseConfig(ctx, nilConfigHandle)
require.ErrorIs(test, err, szerror.ErrSz)
}

func TestSzconfig_CreateConfig(test *testing.T) {
ctx := context.TODO()
Expand All @@ -114,9 +148,6 @@ func TestSzconfig_CreateConfig(test *testing.T) {
printActual(test, actual)
}

// TODO: Implement TestSzconfig_CreateConfig_error
// func TestSzconfig_CreateConfig_error(test *testing.T) {}

func TestSzconfig_DeleteDataSource(test *testing.T) {
ctx := context.TODO()
szConfig := getTestObject(ctx, test)
Expand All @@ -126,7 +157,6 @@ func TestSzconfig_DeleteDataSource(test *testing.T) {
actual, err := szConfig.GetDataSources(ctx, configHandle)
require.NoError(test, err)
printResult(test, "Original", actual)
dataSourceCode := "GO_TEST"
_, err = szConfig.AddDataSource(ctx, configHandle, dataSourceCode)
require.NoError(test, err)
actual, err = szConfig.GetDataSources(ctx, configHandle)
Expand All @@ -149,7 +179,6 @@ func TestSzconfig_DeleteDataSource_withLoad(test *testing.T) {
actual, err := szConfig.GetDataSources(ctx, configHandle)
require.NoError(test, err)
printResult(test, "Original", actual)
dataSourceCode := "GO_TEST"
_, err = szConfig.AddDataSource(ctx, configHandle, dataSourceCode)
require.NoError(test, err)
actual, err = szConfig.GetDataSources(ctx, configHandle)
Expand All @@ -173,7 +202,6 @@ func TestSzconfig_DeleteDataSource_withLoad(test *testing.T) {
func TestSzconfig_DeleteDataSource_badConfigHandle(test *testing.T) {
ctx := context.TODO()
szConfig := getTestObject(ctx, test)
dataSourceCode := "GO_TEST"
err := szConfig.DeleteDataSource(ctx, badConfigHandle, dataSourceCode)
require.ErrorIs(test, err, szerror.ErrSz)
}
Expand All @@ -187,6 +215,22 @@ func TestSzconfig_DeleteDataSource_badDataSourceCode(test *testing.T) {
require.ErrorIs(test, err, szerror.ErrSzBadInput)
}

func TestSzconfig_DeleteDataSource_nilConfigHandle(test *testing.T) {
ctx := context.TODO()
szConfig := getTestObject(ctx, test)
err := szConfig.DeleteDataSource(ctx, nilConfigHandle, dataSourceCode)
require.ErrorIs(test, err, szerror.ErrSz)
}

func TestSzconfig_DeleteDataSource_nilDataSourceCode(test *testing.T) {
ctx := context.TODO()
szConfig := getTestObject(ctx, test)
configHandle, err := szConfig.CreateConfig(ctx)
require.NoError(test, err)
err = szConfig.DeleteDataSource(ctx, configHandle, nilDataSourceCode)
require.NoError(test, err)
}

func TestSzconfig_ExportConfig(test *testing.T) {
ctx := context.TODO()
szConfig := getTestObject(ctx, test)
Expand All @@ -205,6 +249,14 @@ func TestSzconfig_ExportConfig_badConfigHandle(test *testing.T) {
require.ErrorIs(test, err, szerror.ErrSz)
}

func TestSzconfig_ExportConfig_nilConfigHandle(test *testing.T) {
ctx := context.TODO()
szConfig := getTestObject(ctx, test)
actual, err := szConfig.ExportConfig(ctx, nilConfigHandle)
assert.Equal(test, "", actual)
require.ErrorIs(test, err, szerror.ErrSz)
}

func TestSzconfig_GetDataSources(test *testing.T) {
ctx := context.TODO()
szConfig := getTestObject(ctx, test)
Expand All @@ -225,6 +277,14 @@ func TestSzconfig_GetDataSources_badConfigHandle(test *testing.T) {
require.ErrorIs(test, err, szerror.ErrSz)
}

func TestSzconfig_GetDataSources_nilConfigHandle(test *testing.T) {
ctx := context.TODO()
szConfig := getTestObject(ctx, test)
actual, err := szConfig.GetDataSources(ctx, nilConfigHandle)
assert.Equal(test, "", actual)
require.ErrorIs(test, err, szerror.ErrSz)
}

func TestSzconfig_ImportConfig(test *testing.T) {
ctx := context.TODO()
szConfig := getTestObject(ctx, test)
Expand All @@ -244,6 +304,13 @@ func TestSzconfig_ImportConfig_badConfigDefinition(test *testing.T) {
require.ErrorIs(test, err, szerror.ErrSzBadInput)
}

func TestSzconfig_ImportConfig_nilConfigDefinition(test *testing.T) {
ctx := context.TODO()
szConfig := getTestObject(ctx, test)
_, err := szConfig.ImportConfig(ctx, nilConfigDefinition)
require.ErrorIs(test, err, szerror.ErrSzBadInput)
}

// ----------------------------------------------------------------------------
// Private methods
// ----------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit b044bde

Please sign in to comment.