- Notifications
You must be signed in to change notification settings - Fork1.1k
feat: add db query for setting interception ended_at field#20437
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
62bef0c8c69f8a4a2573d4d08f9d151146c8a9f984e2fc3d6File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -7724,3 +7724,68 @@ func TestUpdateTaskWorkspaceID(t *testing.T) { | ||
| }) | ||
| } | ||
| } | ||
| func TestUpdateAIBridgeInterceptionEnded(t *testing.T) { | ||
| t.Parallel() | ||
| db, _ := dbtestutil.NewDB(t) | ||
| t.Run("NonExistingInterception", func(t *testing.T) { | ||
| t.Parallel() | ||
| ctx := testutil.Context(t, testutil.WaitLong) | ||
| got, err := db.UpdateAIBridgeInterceptionEnded(ctx, database.UpdateAIBridgeInterceptionEndedParams{ | ||
| ID: uuid.New(), | ||
| EndedAt: time.Now(), | ||
| }) | ||
| require.ErrorContains(t, err, "no rows in result set") | ||
pawbana marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| require.EqualValues(t, database.AIBridgeInterception{}, got) | ||
| }) | ||
| t.Run("OK", func(t *testing.T) { | ||
| t.Parallel() | ||
| ctx := testutil.Context(t, testutil.WaitLong) | ||
| user := dbgen.User(t, db, database.User{}) | ||
| interceptions := []database.AIBridgeInterception{} | ||
| for _, uid := range []uuid.UUID{{1}, {2}, {3}} { | ||
| insertParams := database.InsertAIBridgeInterceptionParams{ | ||
| ID: uid, | ||
| InitiatorID: user.ID, | ||
| Metadata: json.RawMessage("{}"), | ||
| } | ||
| intc, err := db.InsertAIBridgeInterception(ctx, insertParams) | ||
| require.NoError(t, err) | ||
| require.Equal(t, uid, intc.ID) | ||
| require.False(t, intc.EndedAt.Valid) | ||
| interceptions = append(interceptions, intc) | ||
| } | ||
| intc0 := interceptions[0] | ||
| endedAt := time.Now() | ||
| // Mark first interception as done | ||
| updated, err := db.UpdateAIBridgeInterceptionEnded(ctx, database.UpdateAIBridgeInterceptionEndedParams{ | ||
| ID: intc0.ID, | ||
| EndedAt: endedAt, | ||
| }) | ||
| require.NoError(t, err) | ||
| require.EqualValues(t, updated.ID, intc0.ID) | ||
| require.True(t, updated.EndedAt.Valid) | ||
| require.WithinDuration(t, endedAt, updated.EndedAt.Time, 5*time.Second) | ||
| // Updating first interception again should fail | ||
| updated, err = db.UpdateAIBridgeInterceptionEnded(ctx, database.UpdateAIBridgeInterceptionEndedParams{ | ||
| ID: intc0.ID, | ||
| EndedAt: endedAt.Add(time.Hour), | ||
| }) | ||
| require.ErrorIs(t, err, sql.ErrNoRows) | ||
| // Other interceptions should not have ended_at set | ||
| for _, intc := range interceptions[1:] { | ||
| got, err := db.GetAIBridgeInterceptionByID(ctx, intc.ID) | ||
| require.NoError(t, err) | ||
| require.False(t, got.EndedAt.Valid) | ||
| } | ||
| }) | ||
| } | ||
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.