Fix up some tests after merging

iam-basics
Jeff Mitchell 6 years ago
parent ce13a18dc4
commit 902ff31126

@ -775,7 +775,7 @@ create table iam_role (
name text,
description text,
scope_id wt_scope_id not null references iam_scope(public_id) on delete cascade on update cascade,
grant_scope_id wt_public_id not null references iam_scope(public_id) on delete cascade on update cascade,
grant_scope_id wt_scope_id not null references iam_scope(public_id) on delete cascade on update cascade,
unique(name, scope_id),
disabled boolean not null default false,
-- version allows optimistic locking of the role when modifying the role

@ -317,7 +317,7 @@ create table iam_role (
name text,
description text,
scope_id wt_scope_id not null references iam_scope(public_id) on delete cascade on update cascade,
grant_scope_id wt_public_id not null references iam_scope(public_id) on delete cascade on update cascade,
grant_scope_id wt_scope_id not null references iam_scope(public_id) on delete cascade on update cascade,
unique(name, scope_id),
disabled boolean not null default false,
-- version allows optimistic locking of the role when modifying the role

@ -244,7 +244,7 @@ func (rw *Db) Create(ctx context.Context, i interface{}, opt ...Option) error {
if !opts.withSkipVetForWrite {
if vetter, ok := i.(VetForWriter); ok {
if err := vetter.VetForWrite(ctx, rw, CreateOp); err != nil {
return fmt.Errorf("create: vet for write failed %w", err)
return fmt.Errorf("create: vet for write failed: %w", err)
}
}
}
@ -412,7 +412,7 @@ func (rw *Db) Update(ctx context.Context, i interface{}, fieldMaskPaths []string
if !opts.withSkipVetForWrite {
if vetter, ok := i.(VetForWriter); ok {
if err := vetter.VetForWrite(ctx, rw, UpdateOp, WithFieldMaskPaths(fieldMaskPaths), WithNullPaths(setToNullPaths)); err != nil {
return NoRowsAffected, fmt.Errorf("update: vet for write failed %w", err)
return NoRowsAffected, fmt.Errorf("update: vet for write failed: %w", err)
}
}
}

@ -340,7 +340,7 @@ func Test_RoleUpdate(t *testing.T) {
grantScopeId: proj2.PublicId,
},
wantErr: true,
wantErrMsg: "update: failed pq: invalid to set grant_scope_id to non-same scope_id when role scope type is project",
wantErrMsg: "update: failed: pq: invalid to set grant_scope_id to non-same scope_id when role scope type is project",
},
{
name: "set grant scope in org",
@ -361,7 +361,7 @@ func Test_RoleUpdate(t *testing.T) {
grantScopeId: proj2.PublicId,
},
wantErr: true,
wantErrMsg: "update: failed pq: grant_scope_id is not a child project of the role scope",
wantErrMsg: "update: failed: pq: grant_scope_id is not a child project of the role scope",
},
{
name: "set grant scope in global",
@ -371,6 +371,8 @@ func Test_RoleUpdate(t *testing.T) {
scopeId: org.PublicId,
grantScopeId: "global",
},
wantErr: true,
wantErrMsg: "update: failed: pq: grant_scope_id is not a child project of the role scope",
},
{
name: "set grant scope to parent",
@ -381,16 +383,7 @@ func Test_RoleUpdate(t *testing.T) {
grantScopeId: org2.PublicId,
},
wantErr: true,
wantErrMsg: "update: failed pq: grant_scope_id is not a child project of the role scope",
},
{
name: "set grant scope from global",
args: args{
name: "set grant scope from global",
fieldMaskPaths: []string{"GrantScopeId"},
scopeId: "global",
grantScopeId: org.PublicId,
},
wantErrMsg: "update: failed: pq: invalid to set grant_scope_id to non-same scope_id when role scope type is project",
},
}
for _, tt := range tests {

Loading…
Cancel
Save