|
9 | 9 | "net/http"
|
10 | 10 | "os"
|
11 | 11 | "strings"
|
12 |
| - "sync/atomic" |
13 | 12 | "testing"
|
14 | 13 | "time"
|
15 | 14 |
|
@@ -1395,63 +1394,7 @@ func TestWorkspaceFilterManual(t *testing.T) {
|
1395 | 1394 | }, testutil.IntervalMedium, "agent status timeout")
|
1396 | 1395 | })
|
1397 | 1396 |
|
1398 |
| - t.Run("FilterQueryHasDeletingByAndUnlicensed", func(t *testing.T) { |
1399 |
| - // this test has a licensed counterpart in enterprise/coderd/workspaces_test.go: FilterQueryHasDeletingByAndLicensed |
1400 |
| - t.Parallel() |
1401 |
| - inactivityTTL := 1 * 24 * time.Hour |
1402 |
| - var setCalled int64 |
1403 |
| - |
1404 |
| - client := coderdtest.New(t, &coderdtest.Options{ |
1405 |
| - IncludeProvisionerDaemon: true, |
1406 |
| - TemplateScheduleStore: schedule.MockTemplateScheduleStore{ |
1407 |
| - SetFn: func(ctx context.Context, db database.Store, template database.Template, options schedule.TemplateScheduleOptions) (database.Template, error) { |
1408 |
| - if atomic.AddInt64(&setCalled, 1) == 2 { |
1409 |
| - assert.Equal(t, inactivityTTL, options.TimeTilDormant) |
1410 |
| - } |
1411 |
| - template.TimeTilDormant = int64(options.TimeTilDormant) |
1412 |
| - return template, nil |
1413 |
| - }, |
1414 |
| - }, |
1415 |
| - }) |
1416 |
| - user := coderdtest.CreateFirstUser(t, client) |
1417 |
| - authToken := uuid.NewString() |
1418 |
| - version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, &echo.Responses{ |
1419 |
| - Parse: echo.ParseComplete, |
1420 |
| - ProvisionPlan: echo.PlanComplete, |
1421 |
| - ProvisionApply: echo.ProvisionApplyWithAgent(authToken), |
1422 |
| - }) |
1423 |
| - template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID) |
1424 |
| - coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID) |
1425 |
| - |
1426 |
| - // update template with inactivity ttl |
1427 |
| - ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong) |
1428 |
| - defer cancel() |
1429 |
| - |
1430 |
| - template, err := client.UpdateTemplateMeta(ctx, template.ID, codersdk.UpdateTemplateMeta{ |
1431 |
| - TimeTilDormantMillis: inactivityTTL.Milliseconds(), |
1432 |
| - }) |
1433 |
| - |
1434 |
| - assert.NoError(t, err) |
1435 |
| - assert.Equal(t, inactivityTTL.Milliseconds(), template.TimeTilDormantMillis) |
1436 |
| - |
1437 |
| - workspace := coderdtest.CreateWorkspace(t, client, user.OrganizationID, template.ID) |
1438 |
| - coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, workspace.LatestBuild.ID) |
1439 |
| - |
1440 |
| - // stop build so workspace is inactive |
1441 |
| - stopBuild := coderdtest.CreateWorkspaceBuild(t, client, workspace, database.WorkspaceTransitionStop) |
1442 |
| - coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, stopBuild.ID) |
1443 |
| - |
1444 |
| - res, err := client.Workspaces(ctx, codersdk.WorkspaceFilter{ |
1445 |
| - FilterQuery: fmt.Sprintf("deleting_by:%s", time.Now().Add(inactivityTTL).Format("2006-01-02")), |
1446 |
| - }) |
1447 |
| - |
1448 |
| - assert.NoError(t, err) |
1449 |
| - // we are expecting that no workspaces are returned as user is unlicensed |
1450 |
| - // and template.TimeTilDormant should be 0 |
1451 |
| - assert.Len(t, res.Workspaces, 0) |
1452 |
| - }) |
1453 |
| - |
1454 |
| - t.Run("DormantAt", func(t *testing.T) { |
| 1397 | + t.Run("IsDormant", func(t *testing.T) { |
1455 | 1398 | // this test has a licensed counterpart in enterprise/coderd/workspaces_test.go: FilterQueryHasDeletingByAndLicensed
|
1456 | 1399 | t.Parallel()
|
1457 | 1400 | client := coderdtest.New(t, &coderdtest.Options{
|
@@ -1484,7 +1427,7 @@ func TestWorkspaceFilterManual(t *testing.T) {
|
1484 | 1427 | require.NoError(t, err)
|
1485 | 1428 |
|
1486 | 1429 | res, err := client.Workspaces(ctx, codersdk.WorkspaceFilter{
|
1487 |
| - FilterQuery: fmt.Sprintf("dormant_at:%s", time.Now().Add(-time.Minute).Format("2006-01-02")), |
| 1430 | + FilterQuery: "is-dormant:true", |
1488 | 1431 | })
|
1489 | 1432 | require.NoError(t, err)
|
1490 | 1433 | require.Len(t, res.Workspaces, 1)
|
|
0 commit comments