Skip to content

fix: fix workspace status filter returning more statuses that requested #7732

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Jun 5, 2023
Next Next commit
WIP unit test for workspace statuses
  • Loading branch information
Emyrk committed May 30, 2023
commit c0e28046f91daa5dd3a8d454c7ecf60f4c23e239
52 changes: 52 additions & 0 deletions coderd/workspaces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"testing"
"time"

"github.com/coder/coder/coderd/database/dbgen"

"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -555,6 +557,56 @@ func TestWorkspaceByOwnerAndName(t *testing.T) {
})
}

func TestWorkspaceFilterAllStatus(t *testing.T) {
client, _, api := coderdtest.NewWithAPI(t, &coderdtest.Options{})

owner := coderdtest.CreateFirstUser(t, client)

file := dbgen.File(t, api.Database, database.File{
CreatedBy: owner.UserID,
})
versionJob := dbgen.ProvisionerJob(t, api.Database, database.ProvisionerJob{
OrganizationID: owner.OrganizationID,
InitiatorID: owner.UserID,
WorkerID: uuid.NullUUID{},
FileID: file.ID,
})
version := dbgen.TemplateVersion(t, api.Database, database.TemplateVersion{
OrganizationID: owner.OrganizationID,
JobID: versionJob.ID,
CreatedBy: owner.UserID,
})
template := dbgen.Template(t, api.Database, database.Template{
OrganizationID: owner.OrganizationID,
ActiveVersionID: version.ID,
CreatedBy: owner.UserID,
})

makeWorkspace := func(workspace database.Workspace) database.Workspace {
workspace.OwnerID = owner.UserID
workspace.OrganizationID = owner.OrganizationID
workspace.TemplateID = template.ID
workspace = dbgen.Workspace(t, api.Database, workspace)

return workspace
}
var _ = makeWorkspace
//makeWorkspace(database.Workspace{
//})

// pending
// starting
// running
// stopping
// stopped
// failed
// canceling
// canceled
// deleted
// deleting

}

// TestWorkspaceFilter creates a set of workspaces, users, and organizations
// to run various filters against for testing.
func TestWorkspaceFilter(t *testing.T) {
Expand Down