Skip to content

Commit

Permalink
Tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
NeilLuno committed Nov 13, 2024
1 parent 7d70cba commit b72dfd0
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
15 changes: 9 additions & 6 deletions rsql/db_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func Test_makeInsertManyQuery(t *testing.T) {

t.Run("one", func(t *testing.T) {
q, args, err := makeInsertManyQuery(ctx, defaultSchema, []EventToInsert{
{"fid1", testEventType(1), nil},
{"fid", testEventType(1), nil},
})
jtest.RequireNil(t, err)
assert(t, q, args)
Expand All @@ -64,7 +64,10 @@ func Test_makeInsertManyQuery(t *testing.T) {
t.Run("more", func(t *testing.T) {
var events []EventToInsert
for i := range 5 {
events = append(events, EventToInsert{"fid", testEventType(i), nil})
events = append(events, EventToInsert{
ForeignID: fmt.Sprintf("fid%d", i+1),
Type: testEventType(i),
})
}
q, args, err := makeInsertManyQuery(ctx, defaultSchema, events)
jtest.RequireNil(t, err)
Expand All @@ -73,16 +76,16 @@ func Test_makeInsertManyQuery(t *testing.T) {

t.Run("metadata_error", func(t *testing.T) {
_, _, err := makeInsertManyQuery(ctx, defaultSchema, []EventToInsert{
{"fid1", testEventType(1), []byte("metadata")},
{"fid", testEventType(1), []byte("metadata")},
})
require.ErrorContains(t, err, "metadata not enable")
require.ErrorContains(t, err, "metadata not enabled")
})

t.Run("with_metadata", func(t *testing.T) {
schemaWithMetadata := defaultSchema
schemaWithMetadata.metadataField = "metadata"
q, args, err := makeInsertManyQuery(ctx, schemaWithMetadata, []EventToInsert{
{"fid1", testEventType(1), []byte("metadata")},
{"fid", testEventType(1), []byte("metadata")},
})
jtest.RequireNil(t, err)
assert(t, q, args)
Expand All @@ -102,7 +105,7 @@ func Test_makeInsertManyQuery(t *testing.T) {
jtest.RequireNil(t, err)
ctx := tracing.Inject(ctx, data)
q, args, err := makeInsertManyQuery(ctx, schemaWithTrace, []EventToInsert{
{"fid1", testEventType(1), nil},
{"fid", testEventType(1), nil},
})
jtest.RequireNil(t, err)
assert(t, q, args)
Expand Down
10 changes: 5 additions & 5 deletions rsql/testdata/Test_makeInsertManyQuery/more.golden
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
insert into events (foreign_id, type, timestamp) values (?, ?, now(6)), (?, ?, now(6)), (?, ?, now(6)), (?, ?, now(6)), (?, ?, now(6))

fid
fid1
0
fid
fid2
1
fid
fid3
2
fid
fid4
3
fid
fid5
4
2 changes: 1 addition & 1 deletion rsql/testdata/Test_makeInsertManyQuery/one.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
insert into events (foreign_id, type, timestamp) values (?, ?, now(6))

fid1
fid
1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
insert into events (foreign_id, type, timestamp, metadata) values (?, ?, now(6), ?)

fid1
fid
1
[109 101 116 97 100 97 116 97]
2 changes: 1 addition & 1 deletion rsql/testdata/Test_makeInsertManyQuery/with_trace.golden
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
insert into events (foreign_id, type, timestamp, trace) values (?, ?, now(6), ?)

fid1
fid
1
[10 32 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 57 18 16 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 50]

0 comments on commit b72dfd0

Please sign in to comment.