From 698956092bf1b0797ffe96c0a3a3f65cda24d2f8 Mon Sep 17 00:00:00 2001 From: zuevav Date: Thu, 17 Sep 2026 12:55:42 +0300 Subject: [PATCH] =?UTF-8?q?=D0=96=D0=B8=D0=B2=D0=BE=D0=B9=20=D1=82=D0=B5?= =?UTF-8?q?=D1=81=D1=82=20=D0=B2=D1=81=D1=82=D0=B0=D0=B2=D0=BA=D0=B8=20?= =?UTF-8?q?=D1=81=D0=BE=D0=B1=D1=8B=D1=82=D0=B8=D1=8F=20FTV=5FM2M=5FEVENTS?= =?UTF-8?q?=20=D0=B2=20=D0=BD=D0=BE=D0=B2=D0=BE=D0=BC=20=D1=84=D0=BE=D1=80?= =?UTF-8?q?=D0=BC=D0=B0=D1=82=D0=B5=20(=D1=81=20=D0=BE=D1=82=D0=BA=D0=B0?= =?UTF-8?q?=D1=82=D0=BE=D0=BC)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5 (1M context) --- internal/lkgateway/evins_live_test.go | 38 +++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 internal/lkgateway/evins_live_test.go diff --git a/internal/lkgateway/evins_live_test.go b/internal/lkgateway/evins_live_test.go new file mode 100644 index 0000000..b4e187a --- /dev/null +++ b/internal/lkgateway/evins_live_test.go @@ -0,0 +1,38 @@ +//go:build live + +package lkgateway + +import ( + "context" + "database/sql" + "testing" + "time" +) + +// Вставка события в новом формате в транзакции с откатом: EVENT_DATE из bj, PARAMETERS, STATE по умолчанию. +func TestEventInsertRollback(t *testing.T) { + rc, _ := NewRuntimeConfig("/var/lib/bj/.bj/setup.json") + db, err := depoEventsDB(rc) + if err != nil { + t.Fatal(err) + } + defer db.Close() + ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second) + defer cancel() + tx, err := db.BeginTx(ctx, nil) + if err != nil { + t.Fatal(err) + } + defer tx.Rollback() + at := time.Date(2026, 9, 17, 9, 22, 24, 0, time.FixedZone("МСК", 3*3600)) + guid := "00000000-0000-4000-8000-000000000017" + _, err = tx.ExecContext(ctx, `INSERT INTO dbo.FTV_M2M_EVENTS (GUID, REFERENCE, EVENT_TYPE, EVENT_DATE, M2M_REJECT_CODE, PARAMETERS) VALUES (@g, @r, @t, @at, @c, @p)`, + sql.Named("g", guid), sql.Named("r", nullStr("")), sql.Named("t", "BJ_ORDER_SENT"), sql.Named("at", at.In(time.FixedZone("МСК", 3*3600)).Format("2006-01-02T15:04:05.000")), + sql.Named("c", nullStr("")), sql.Named("p", nullStr("20608"))) + if err != nil { + t.Fatal(err) + } + var st, dt, par, cmt sql.NullString + err = tx.QueryRowContext(ctx, `SELECT STATE, CONVERT(varchar(23), EVENT_DATE, 121), CAST(PARAMETERS AS nvarchar(100)), COMMENT FROM dbo.FTV_M2M_EVENTS WHERE GUID=@g`, sql.Named("g", guid)).Scan(&st, &dt, &par, &cmt) + t.Logf("STATE=%q EVENT_DATE=%q PARAMETERS=%q COMMENT=%v (err %v) — откат", st.String, dt.String, par.String, cmt.Valid, err) +}