ICU-738/Refactor internal/db to domain errors (#815)

* Refactor internal/db to domain errors
This commit is contained in:
Louis Ruch authored and GitHub committed 2020-12-21 10:07:34 -08:00
1 parent b5d84495a3
commit bfbb179741
82 files changed
+742 -640

No files matched your search

+1 -1
View File
@@ -150,7 +150,7 @@ func TestConnectionState_Delete(t *testing.T) {
foundState := allocConnectionState()
err = rw.LookupWhere(context.Background(), &foundState, "connection_id = ? and start_time = ?", tt.state.ConnectionId, initialState.StartTime)
require.Error(err)
assert.True(errors.Is(errors.ErrRecordNotFound, err))
assert.True(errors.IsNotFoundError(err))
})
}
}
+1 -1
View File
@@ -195,7 +195,7 @@ func TestConnection_Delete(t *testing.T) {
foundConnection.PublicId = tt.connection.PublicId
err = rw.LookupById(context.Background(), &foundConnection)
require.Error(err)
assert.True(errors.Is(errors.ErrRecordNotFound, err))
assert.True(errors.IsNotFoundError(err))
})
}
}
+1 -1
View File
@@ -35,7 +35,7 @@ func (r *Repository) LookupConnection(ctx context.Context, connectionId string,
},
)
if err != nil {
if errors.Is(err, errors.ErrRecordNotFound) {
if errors.IsNotFoundError(err) {
return nil, nil, nil
}
return nil, nil, fmt.Errorf("lookup connection: %w", err)
@@ -184,7 +184,7 @@ func TestRepository_DeleteConnection(t *testing.T) {
},
wantRowsDeleted: 0,
wantErr: true,
wantErrMsg: "delete connection: failed record not found:",
wantErrMsg: "delete connection: failed db.LookupById: record not found",
},
}
for _, tt := range tests {
@@ -197,7 +197,7 @@ func TestRepository_DeleteConnection(t *testing.T) {
assert.Contains(err.Error(), tt.wantErrMsg)
err = db.TestVerifyOplog(t, rw, tt.args.connection.PublicId, db.WithOperation(oplog.OpType_OP_TYPE_DELETE), db.WithCreateNotBefore(10*time.Second))
assert.Error(err)
assert.True(errors.Is(errors.ErrRecordNotFound, err))
assert.True(errors.IsNotFoundError(err))
return
}
assert.NoError(err)
+1 -1
View File
@@ -138,7 +138,7 @@ func (r *Repository) LookupSession(ctx context.Context, sessionId string, opt ..
},
)
if err != nil {
if errors.Is(err, errors.ErrRecordNotFound) {
if errors.IsNotFoundError(err) {
return nil, nil, nil
}
return nil, nil, fmt.Errorf("lookup session: %w", err)
+2 -2
View File
@@ -1532,7 +1532,7 @@ func TestRepository_DeleteSession(t *testing.T) {
},
wantRowsDeleted: 0,
wantErr: true,
wantErrMsg: "delete session: failed record not found:",
wantErrMsg: "delete session: failed db.LookupById: record not found",
},
}
for _, tt := range tests {
@@ -1545,7 +1545,7 @@ func TestRepository_DeleteSession(t *testing.T) {
assert.Contains(err.Error(), tt.wantErrMsg)
err = db.TestVerifyOplog(t, rw, tt.args.session.PublicId, db.WithOperation(oplog.OpType_OP_TYPE_DELETE), db.WithCreateNotBefore(10*time.Second))
assert.Error(err)
assert.True(errors.Is(errors.ErrRecordNotFound, err))
assert.True(errors.IsNotFoundError(err))
return
}
assert.NoError(err)
+1 -1
View File
@@ -213,7 +213,7 @@ func TestSession_Delete(t *testing.T) {
foundSession.PublicId = tt.session.PublicId
err = rw.LookupById(context.Background(), &foundSession)
require.Error(err)
assert.True(errors.Is(errors.ErrRecordNotFound, err))
assert.True(errors.IsNotFoundError(err))
})
}
}
+1 -1
View File
@@ -148,7 +148,7 @@ func TestState_Delete(t *testing.T) {
foundState := allocState()
err = rw.LookupWhere(context.Background(), &foundState, "session_id = ? and start_time = ?", tt.state.SessionId, initialState.StartTime)
require.Error(err)
assert.True(errors.Is(errors.ErrRecordNotFound, err))
assert.True(errors.IsNotFoundError(err))
})
}
}