Skip to content

Commit

Permalink
fix: correct testing admin setting
Browse files Browse the repository at this point in the history
  • Loading branch information
corban-beaird committed Jun 7, 2024
1 parent 668e4a1 commit 67a75c5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
10 changes: 4 additions & 6 deletions master/internal/project/postgres_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func GetProjectByKey(ctx context.Context, key string) (*model.Project, error) {
err := tx.NewSelect().
Column("id").
Table("projects").
Where("key = ?", key).
Where("key = UPPER(?)", key). // case-insensitive
Scan(ctx, &projectID)
if err != nil && errors.Is(err, sql.ErrNoRows) {
return db.ErrNotFound
Expand Down Expand Up @@ -204,7 +204,6 @@ RetryLoop:
p.Key = *requestedKey
}
_, err = tx.NewInsert().Model(p).Exec(ctx)

if err != nil && strings.Contains(err.Error(), db.CodeUniqueViolation) {
switch errString := err.Error(); {
case strings.Contains(errString, "projects_key_key"):
Expand Down Expand Up @@ -303,7 +302,7 @@ func UpdateProject(
return status.Error(codes.PermissionDenied, err.Error())
}
log.Infof(
"project (%d) name changing from \"%s\" to \"%s\"",
`project (%d) name changing from "%s" to "%s"`,
currentProject.ID,
currentProject.Name,
p.Name.Value,
Expand All @@ -317,7 +316,7 @@ func UpdateProject(
return status.Error(codes.PermissionDenied, err.Error())
}
log.Infof(
"project (%d) description changing from \"%s\" to \"%s\"",
`project (%d) description changing from "%s" to "%s"`,
currentProject.ID,
currentProject.Description,
p.Description.Value,
Expand All @@ -331,7 +330,7 @@ func UpdateProject(
return status.Error(codes.PermissionDenied, err.Error())
}
log.Infof(
"project (%d) key changing from \"%s\" to \"%s\"",
`project (%d) key changing from "%s" to "%s"`,
currentProject.ID,
currentProject.Key,
p.Key.Value,
Expand Down Expand Up @@ -389,7 +388,6 @@ func UpdateProject(
Apply(getProjectColumns).
Where("p.id = ?", projectID).
Scan(ctx)
// finalProject, err = GetProjectByID(ctx, currentProject.ID)
if err != nil {
return err
}
Expand Down
10 changes: 9 additions & 1 deletion master/internal/project/postgres_project_intg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,15 @@ func TestGetProjectByKey(t *testing.T) {
internaldb.MustMigrateTestPostgres(t, db, internaldb.MigrationsFromDB)

// add a workspace, and project
user := internaldb.RequireMockUser(t, db)
user := model.User{
Username: uuid.Must(uuid.NewRandom()).String(),
Admin: true,
}
_, err := internaldb.HackAddUser(
context.Background(),
&user,
)
require.NoError(t, err)
workspaceID, _ := internaldb.RequireMockWorkspaceID(t, db, "")
projectID, _ := internaldb.RequireMockProjectID(t, db, workspaceID, false)

Expand Down

0 comments on commit 67a75c5

Please sign in to comment.