Skip to content

Commit

Permalink
#4909: fixed json column tests on fast batch builder
Browse files Browse the repository at this point in the history
  • Loading branch information
sreuland committed Oct 17, 2023
1 parent c1d5ce7 commit 30ed273
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
15 changes: 8 additions & 7 deletions support/db/fast_batch_insert_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"testing"

"github.com/guregu/null"
"github.com/stretchr/testify/assert"

"github.com/stellar/go/support/db/dbtest"
Expand All @@ -21,7 +22,7 @@ func TestFastBatchInsertBuilder(t *testing.T) {
insertBuilder.Row(map[string]interface{}{
"name": "bubba",
"hunger_level": "1",
"json_value": []byte(`{\"bump_to\":\"98\"}`),
"json_value": []byte(`{"bump_to": "97"}`),
}),
)

Expand All @@ -36,7 +37,7 @@ func TestFastBatchInsertBuilder(t *testing.T) {
insertBuilder.Row(map[string]interface{}{
"name": "bubba",
"city": "London",
"json_value": []byte(`{\"bump_to\":\"98\"}`),
"json_value": []byte(`{"bump_to": "98"}`),
}),
"column \"hunger_level\" does not exist",
)
Expand All @@ -45,7 +46,7 @@ func TestFastBatchInsertBuilder(t *testing.T) {
insertBuilder.RowStruct(hungerRow{
Name: "bubba2",
HungerLevel: "9",
JsonValue: []byte(`{\"bump_to\":\"98\"}`),
JsonValue: []byte(`{"bump_to": "98"}`),
}),
)

Expand Down Expand Up @@ -77,8 +78,8 @@ func TestFastBatchInsertBuilder(t *testing.T) {
t,
found,
[]person{
{Name: "bubba", HungerLevel: "1"},
{Name: "bubba2", HungerLevel: "9"},
{Name: "bubba", HungerLevel: "1", JsonValue: null.NewString(`{"bump_to": "97"}`, true)},
{Name: "bubba2", HungerLevel: "9", JsonValue: null.NewString(`{"bump_to": "98"}`, true)},
},
)

Expand Down Expand Up @@ -119,8 +120,8 @@ func TestFastBatchInsertBuilder(t *testing.T) {
t,
found,
[]person{
{Name: "bubba", HungerLevel: "1"},
{Name: "bubba2", HungerLevel: "9"},
{Name: "bubba", HungerLevel: "1", JsonValue: null.NewString(`{"bump_to": "97"}`, true)},
{Name: "bubba2", HungerLevel: "9", JsonValue: null.NewString(`{"bump_to": "98"}`, true)},
},
)
assert.NoError(t, sess.Rollback())
Expand Down
9 changes: 5 additions & 4 deletions support/db/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ import (
"testing"
"time"

"github.com/guregu/null"
"github.com/stellar/go/support/db/dbtest"
"github.com/stretchr/testify/assert"
)

type person struct {
Name string `db:"name"`
HungerLevel string `db:"hunger_level"`

SomethingIgnored int `db:"-"`
Name string `db:"name"`
HungerLevel string `db:"hunger_level"`
JsonValue null.String `db:"json_value"`

Check failure on line 15 in support/db/main_test.go

View workflow job for this annotation

GitHub Actions / golangci

ST1003: struct field JsonValue should be JSONValue (stylecheck)
SomethingIgnored int `db:"-"`
}

func TestGetTable(t *testing.T) {
Expand Down

0 comments on commit 30ed273

Please sign in to comment.