8000 feat(coderd/database): add support for presets by SasSwart · Pull Request #16509 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

feat(coderd/database): add support for presets #16509

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 6 commits into from
Feb 11, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
8000
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix tests
  • Loading branch information
SasSwart committed Feb 11, 2025
commit 5bb5d1f5ffdc86edf2c3d93301b7f989de382d32
21 changes: 8 additions & 13 deletions coderd/database/dbauthz/dbauthz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,6 @@ func (s *MethodTestSuite) TestOrganization() {
rbac.ResourceOrganizationMember.InOrg(o.ID).WithID(u.ID), policy.ActionCreate)
}))
s.Run("InsertPreset", s.Subtest(func(db database.Store, check *expects) {
ctx := context.Background()
org := dbgen.Organization(s.T(), db, database.Organization{})
user := dbgen.User(s.T(), db, database.User{})
template := dbgen.Template(s.T(), db, database.Template{
Expand Down Expand Up @@ -891,8 +890,6 @@ func (s *MethodTestSuite) TestOrganization() {
TemplateVersionID: workspaceBuild.TemplateVersionID,
Name: "test",
}
_, err := db.InsertPreset(ctx, insertPresetParams)
require.NoError(s.T(), err)
check.Args(insertPresetParams).Asserts(rbac.ResourceTemplate, policy.ActionUpdate)
}))
s.Run("InsertPresetParameters", s.Subtest(func(db database.Store, check *expects) {
Expand Down Expand Up @@ -932,8 +929,6 @@ func (s *MethodTestSuite) TestOrganization() {
Names: []string{"test"},
Values: []string{"test"},
}
_, err = db.InsertPresetParameters(context.Background(), insertPresetParametersParams)
require.NoError(s.T(), err)
check.Args(insertPresetParametersParams).Asserts(rbac.ResourceTemplate, policy.ActionUpdate)
}))
s.Run("DeleteOrganizationMember", s.Subtest(func(db database.Store, check *expects) {
Expand Down Expand Up @@ -3741,7 +3736,7 @@ func (s *MethodTestSuite) TestSystemFunctions() {
s.Run("GetProvisionerJobsCreatedAfter", s.Subtest(func(db database.Store, check *expects) {
// TODO: add provisioner job resource type
_ = dbgen.ProvisionerJob(s.T(), db, nil, database.ProvisionerJob{CreatedAt: time.Now().Add(-time.Hour)})
check.Args(time.Now()).Asserts( /*rbac.ResourceSystem, policy.ActionRead*/ )
check.Args(time.Now()).Asserts( /*rbac.ResourceSystem, policy.ActionRead*/)
}))
s.Run("GetTemplateVersionsByIDs", s.Subtest(func(db database.Store, check *expects) {
dbtestutil.DisableForeignKeysAndTriggers(s.T(), db)
Expand Down Expand Up @@ -3920,7 +3915,7 @@ func (s *MethodTestSuite) TestSystemFunctions() {
a := dbgen.ProvisionerJob(s.T(), db, nil, database.ProvisionerJob{})
b := dbgen.ProvisionerJob(s.T(), db, nil, database.ProvisionerJob{})
check.Args([]uuid.UUID{a.ID, b.ID}).
Asserts( /*rbac.ResourceSystem, policy.ActionRead*/ ).
Asserts( /*rbac.ResourceSystem, policy.ActionRead*/).
Returns(slice.New(a, b))
}))
s.Run("InsertWorkspaceAgent", s.Subtest(func(db database.Store, check *expects) {
Expand Down Expand Up @@ -3964,22 +3959,22 @@ func (s *MethodTestSuite) TestSystemFunctions() {
OrganizationID: j.OrganizationID,
Types: []database.ProvisionerType{j.Provisioner},
ProvisionerTags: must(json.Marshal(j.Tags)),
}).Asserts( /*rbac.ResourceSystem, policy.ActionUpdate*/ )
}).Asserts( /*rbac.ResourceSystem, policy.ActionUpdate*/)
}))
s.Run("UpdateProvisionerJobWithCompleteByID", s.Subtest(func(db database.Store, check *expects) {
// TODO: we need to create a ProvisionerJob resource
j := dbgen.ProvisionerJob(s.T(), db, nil, database.ProvisionerJob{})
check.Args(database.UpdateProvisionerJobWithCompleteByIDParams{
ID: j.ID,
}).Asserts( /*rbac.ResourceSystem, policy.ActionUpdate*/ )
}).Asserts( /*rbac.ResourceSystem, policy.ActionUpdate*/)
}))
s.Run("UpdateProvisionerJobByID", s.Subtest(func(db database.Store, check *expects) {
// TODO: we need to create a ProvisionerJob resource
j := dbgen.ProvisionerJob(s.T(), db, nil, database.ProvisionerJob{})
check.Args(database.UpdateProvisionerJobByIDParams{
ID: j.ID,
UpdatedAt: time.Now(),
}).Asserts( /*rbac.ResourceSystem, policy.ActionUpdate*/ )
}).Asserts( /*rbac.ResourceSystem, policy.ActionUpdate*/)
}))
s.Run("InsertProvisionerJob", s.Subtest(func(db database.Store, check *expects) {
dbtestutil.DisableForeignKeysAndTriggers(s.T(), db)
Expand All @@ -3990,21 +3985,21 @@ func (s *MethodTestSuite) TestSystemFunctions() {
StorageMethod: database.ProvisionerStorageMethodFile,
Type: database.ProvisionerJobTypeWorkspaceBuild,
Input: json.RawMessage("{}"),
}).Asserts( /*rbac.ResourceSystem, policy.ActionCreate*/ )
}).Asserts( /*rbac.ResourceSystem, policy.ActionCreate*/)
}))
s.Run("InsertProvisionerJobLogs", s.Subtest(func(db database.Store, check *expects) {
// TODO: we need to create a ProvisionerJob resource
j := dbgen.ProvisionerJob(s.T(), db, nil, database.ProvisionerJob{})
check.Args(database.InsertProvisionerJobLogsParams{
JobID: j.ID,
}).Asserts( /*rbac.ResourceSystem, policy.ActionCreate*/ )
}).Asserts( /*rbac.ResourceSystem, policy.ActionCreate*/)
}))
s.Run("InsertProvisionerJobTimings", s.Subtest(func(db database.Store, check *expects) {
// TODO: we need to create a ProvisionerJob resource
j := dbgen.ProvisionerJob(s.T(), db, nil, database.ProvisionerJob{})
check.Args(database.InsertProvisionerJobTimingsParams{
JobID: j.ID,
}).Asserts( /*rbac.ResourceSystem, policy.ActionCreate*/ )
}).Asserts( /*rbac.ResourceSystem, policy.ActionCreate*/)
}))
s.Run("UpsertProvisionerDaemon", s.Subtest(func(db database.Store, check *expects) {
dbtestutil.DisableForeignKeysAndTriggers(s.T(), db)
Expand Down
Loading
0