(t *testing.T)
| 3628 | } |
| 3629 | |
| 3630 | func TestConnectionLogsOffsetFilters(t *testing.T) { |
| 3631 | t.Parallel() |
| 3632 | |
| 3633 | db, _ := dbtestutil.NewDB(t) |
| 3634 | |
| 3635 | orgA := dbfake.Organization(t, db).Do() |
| 3636 | orgB := dbfake.Organization(t, db).Do() |
| 3637 | |
| 3638 | user1 := dbgen.User(t, db, database.User{ |
| 3639 | Username: "user1", |
| 3640 | Email: "user1@test.com", |
| 3641 | }) |
| 3642 | user2 := dbgen.User(t, db, database.User{ |
| 3643 | Username: "user2", |
| 3644 | Email: "user2@test.com", |
| 3645 | }) |
| 3646 | user3 := dbgen.User(t, db, database.User{ |
| 3647 | Username: "user3", |
| 3648 | Email: "user3@test.com", |
| 3649 | }) |
| 3650 | |
| 3651 | ws1Tpl := dbgen.Template(t, db, database.Template{OrganizationID: orgA.Org.ID, CreatedBy: user1.ID}) |
| 3652 | ws1 := dbgen.Workspace(t, db, database.WorkspaceTable{ |
| 3653 | OwnerID: user1.ID, |
| 3654 | OrganizationID: orgA.Org.ID, |
| 3655 | TemplateID: ws1Tpl.ID, |
| 3656 | }) |
| 3657 | ws2Tpl := dbgen.Template(t, db, database.Template{OrganizationID: orgB.Org.ID, CreatedBy: user2.ID}) |
| 3658 | ws2 := dbgen.Workspace(t, db, database.WorkspaceTable{ |
| 3659 | OwnerID: user2.ID, |
| 3660 | OrganizationID: orgB.Org.ID, |
| 3661 | TemplateID: ws2Tpl.ID, |
| 3662 | }) |
| 3663 | |
| 3664 | now := dbtime.Now() |
| 3665 | log1ConnID := uuid.New() |
| 3666 | log1 := dbgen.ConnectionLog(t, db, database.UpsertConnectionLogParams{ |
| 3667 | Time: now.Add(-4 * time.Hour), |
| 3668 | OrganizationID: ws1.OrganizationID, |
| 3669 | WorkspaceOwnerID: ws1.OwnerID, |
| 3670 | WorkspaceID: ws1.ID, |
| 3671 | WorkspaceName: ws1.Name, |
| 3672 | Type: database.ConnectionTypeWorkspaceApp, |
| 3673 | ConnectionStatus: database.ConnectionStatusConnected, |
| 3674 | UserID: uuid.NullUUID{UUID: user1.ID, Valid: true}, |
| 3675 | UserAgent: sql.NullString{String: "Mozilla/5.0", Valid: true}, |
| 3676 | SlugOrPort: sql.NullString{String: "code-server", Valid: true}, |
| 3677 | ConnectionID: uuid.NullUUID{UUID: log1ConnID, Valid: true}, |
| 3678 | }) |
| 3679 | |
| 3680 | log2ConnID := uuid.New() |
| 3681 | log2 := dbgen.ConnectionLog(t, db, database.UpsertConnectionLogParams{ |
| 3682 | Time: now.Add(-3 * time.Hour), |
| 3683 | OrganizationID: ws1.OrganizationID, |
| 3684 | WorkspaceOwnerID: ws1.OwnerID, |
| 3685 | WorkspaceID: ws1.ID, |
| 3686 | WorkspaceName: ws1.Name, |
| 3687 | Type: database.ConnectionTypeVscode, |
nothing calls this directly
no test coverage detected