mirror of
https://github.com/coder/coder.git
synced 2025-07-15 22:20:27 +00:00
chore: Rename databasefake --> dbfake (#6011)
This commit is contained in:
@ -8,7 +8,7 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/coder/coder/coderd/database"
|
||||
"github.com/coder/coder/coderd/database/databasefake"
|
||||
"github.com/coder/coder/coderd/database/dbfake"
|
||||
"github.com/coder/coder/coderd/database/dbgen"
|
||||
)
|
||||
|
||||
@ -17,7 +17,7 @@ func TestGenerator(t *testing.T) {
|
||||
|
||||
t.Run("AuditLog", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
db := databasefake.New()
|
||||
db := dbfake.New()
|
||||
_ = dbgen.AuditLog(t, db, database.AuditLog{})
|
||||
logs := must(db.GetAuditLogsOffset(context.Background(), database.GetAuditLogsOffsetParams{Limit: 1}))
|
||||
require.Len(t, logs, 1)
|
||||
@ -25,56 +25,56 @@ func TestGenerator(t *testing.T) {
|
||||
|
||||
t.Run("APIKey", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
db := databasefake.New()
|
||||
db := dbfake.New()
|
||||
exp, _ := dbgen.APIKey(t, db, database.APIKey{})
|
||||
require.Equal(t, exp, must(db.GetAPIKeyByID(context.Background(), exp.ID)))
|
||||
})
|
||||
|
||||
t.Run("File", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
db := databasefake.New()
|
||||
db := dbfake.New()
|
||||
exp := dbgen.File(t, db, database.File{})
|
||||
require.Equal(t, exp, must(db.GetFileByID(context.Background(), exp.ID)))
|
||||
})
|
||||
|
||||
t.Run("UserLink", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
db := databasefake.New()
|
||||
db := dbfake.New()
|
||||
exp := dbgen.UserLink(t, db, database.UserLink{})
|
||||
require.Equal(t, exp, must(db.GetUserLinkByLinkedID(context.Background(), exp.LinkedID)))
|
||||
})
|
||||
|
||||
t.Run("WorkspaceResource", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
db := databasefake.New()
|
||||
db := dbfake.New()
|
||||
exp := dbgen.WorkspaceResource(t, db, database.WorkspaceResource{})
|
||||
require.Equal(t, exp, must(db.GetWorkspaceResourceByID(context.Background(), exp.ID)))
|
||||
})
|
||||
|
||||
t.Run("WorkspaceResourceMetadatum", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
db := databasefake.New()
|
||||
db := dbfake.New()
|
||||
exp := dbgen.WorkspaceResourceMetadatums(t, db, database.WorkspaceResourceMetadatum{})
|
||||
require.Equal(t, exp, must(db.GetWorkspaceResourceMetadataByResourceIDs(context.Background(), []uuid.UUID{exp[0].WorkspaceResourceID})))
|
||||
})
|
||||
|
||||
t.Run("Job", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
db := databasefake.New()
|
||||
db := dbfake.New()
|
||||
exp := dbgen.ProvisionerJob(t, db, database.ProvisionerJob{})
|
||||
require.Equal(t, exp, must(db.GetProvisionerJobByID(context.Background(), exp.ID)))
|
||||
})
|
||||
|
||||
t.Run("Group", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
db := databasefake.New()
|
||||
db := dbfake.New()
|
||||
exp := dbgen.Group(t, db, database.Group{})
|
||||
require.Equal(t, exp, must(db.GetGroupByID(context.Background(), exp.ID)))
|
||||
})
|
||||
|
||||
t.Run("GroupMember", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
db := databasefake.New()
|
||||
db := dbfake.New()
|
||||
g := dbgen.Group(t, db, database.Group{})
|
||||
u := dbgen.User(t, db, database.User{})
|
||||
exp := []database.User{u}
|
||||
@ -85,14 +85,14 @@ func TestGenerator(t *testing.T) {
|
||||
|
||||
t.Run("Organization", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
db := databasefake.New()
|
||||
db := dbfake.New()
|
||||
exp := dbgen.Organization(t, db, database.Organization{})
|
||||
require.Equal(t, exp, must(db.GetOrganizationByID(context.Background(), exp.ID)))
|
||||
})
|
||||
|
||||
t.Run("OrganizationMember", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
db := databasefake.New()
|
||||
db := dbfake.New()
|
||||
exp := dbgen.OrganizationMember(t, db, database.OrganizationMember{})
|
||||
require.Equal(t, exp, must(db.GetOrganizationMemberByUserID(context.Background(), database.GetOrganizationMemberByUserIDParams{
|
||||
OrganizationID: exp.OrganizationID,
|
||||
@ -102,42 +102,42 @@ func TestGenerator(t *testing.T) {
|
||||
|
||||
t.Run("Workspace", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
db := databasefake.New()
|
||||
db := dbfake.New()
|
||||
exp := dbgen.Workspace(t, db, database.Workspace{})
|
||||
require.Equal(t, exp, must(db.GetWorkspaceByID(context.Background(), exp.ID)))
|
||||
})
|
||||
|
||||
t.Run("WorkspaceAgent", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
db := databasefake.New()
|
||||
db := dbfake.New()
|
||||
exp := dbgen.WorkspaceAgent(t, db, database.WorkspaceAgent{})
|
||||
require.Equal(t, exp, must(db.GetWorkspaceAgentByID(context.Background(), exp.ID)))
|
||||
})
|
||||
|
||||
t.Run("Template", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
db := databasefake.New()
|
||||
db := dbfake.New()
|
||||
exp := dbgen.Template(t, db, database.Template{})
|
||||
require.Equal(t, exp, must(db.GetTemplateByID(context.Background(), exp.ID)))
|
||||
})
|
||||
|
||||
t.Run("TemplateVersion", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
db := databasefake.New()
|
||||
db := dbfake.New()
|
||||
exp := dbgen.TemplateVersion(t, db, database.TemplateVersion{})
|
||||
require.Equal(t, exp, must(db.GetTemplateVersionByID(context.Background(), exp.ID)))
|
||||
})
|
||||
|
||||
t.Run("ParameterSchema", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
db := databasefake.New()
|
||||
db := dbfake.New()
|
||||
exp := dbgen.ParameterSchema(t, db, database.ParameterSchema{})
|
||||
require.Equal(t, []database.ParameterSchema{exp}, must(db.GetParameterSchemasByJobID(context.Background(), exp.JobID)))
|
||||
})
|
||||
|
||||
t.Run("ParameterValue", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
db := databasefake.New()
|
||||
db := dbfake.New()
|
||||
exp := dbgen.ParameterValue(t, db, database.ParameterValue{})
|
||||
require.Equal(t, exp, must(db.GetParameterValueByScopeAndName(context.Background(), database.GetParameterValueByScopeAndNameParams{
|
||||
Scope: exp.Scope,
|
||||
@ -148,14 +148,14 @@ func TestGenerator(t *testing.T) {
|
||||
|
||||
t.Run("WorkspaceBuild", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
db := databasefake.New()
|
||||
db := dbfake.New()
|
||||
exp := dbgen.WorkspaceBuild(t, db, database.WorkspaceBuild{})
|
||||
require.Equal(t, exp, must(db.GetWorkspaceBuildByID(context.Background(), exp.ID)))
|
||||
})
|
||||
|
||||
t.Run("User", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
db := databasefake.New()
|
||||
db := dbfake.New()
|
||||
exp := dbgen.User(t, db, database.User{})
|
||||
require.Equal(t, exp, must(db.GetUserByID(context.Background(), exp.ID)))
|
||||
})
|
||||
|
Reference in New Issue
Block a user