Skip to content

Commit

Permalink
RHCLOUD-36941 - Fix tests that have actuals in expected parameter (#311)
Browse files Browse the repository at this point in the history
* Swap tests expected and actual values around

Signed-off-by: Jonathan Marcantonio <[email protected]>

* swap validation tests

Signed-off-by: Jonathan Marcantonio <[email protected]>

* remaining status codes should be actuals

Signed-off-by: Jonathan Marcantonio <[email protected]>

---------

Signed-off-by: Jonathan Marcantonio <[email protected]>
  • Loading branch information
lennysgarage authored Dec 19, 2024
1 parent 9799e31 commit 5e351f0
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions internal/data/spicedb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func TestSecondCreateRelationshipFailsWithTouchFalse(t *testing.T) {

err = spiceDbRepo.CreateRelationships(ctx, rels, touch)
assert.Error(t, err)
assert.Equal(t, status.Convert(err).Code(), codes.AlreadyExists)
assert.Equal(t, codes.AlreadyExists, status.Convert(err).Code())

container.WaitForQuantizationInterval()

Expand Down Expand Up @@ -338,7 +338,7 @@ func TestCreateRelationshipFailsWithBadSubjectType(t *testing.T) {

err = spiceDbRepo.CreateRelationships(ctx, rels, touch)
assert.Error(t, err)
assert.Equal(t, status.Convert(err).Code(), codes.FailedPrecondition)
assert.Equal(t, codes.FailedPrecondition, status.Convert(err).Code())
assert.Contains(t, err.Error(),
fmt.Sprintf("object definition `%s/%s` not found", "rbac", badSubjectType))
}
Expand All @@ -360,7 +360,7 @@ func TestCreateRelationshipFailsWithBadObjectType(t *testing.T) {

err = spiceDbRepo.CreateRelationships(ctx, rels, touch)
assert.Error(t, err)
assert.Equal(t, status.Convert(err).Code(), codes.FailedPrecondition)
assert.Equal(t, codes.FailedPrecondition, status.Convert(err).Code())
assert.Contains(t, err.Error(),
fmt.Sprintf("object definition `%s/%s` not found", "rbac", badObjectType))

Expand Down
2 changes: 1 addition & 1 deletion internal/server/middleware/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestValidationMiddleware_InvalidRequest(t *testing.T) {
Resource: &v1beta1.ObjectReference{},
})
assert.Error(t, err)
assert.Equal(t, resp, nil)
assert.Equal(t, nil, resp)
}

type DummyServerStream struct {
Expand Down
12 changes: 6 additions & 6 deletions internal/service/health_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestHealthService_GetLivez(t *testing.T) {
resp, err := service.GetLivez(ctx, &pb.GetLivezRequest{})

assert.NoError(t, err)
assert.Equal(t, resp, &pb.GetLivezResponse{Status: "OK", Code: 200})
assert.Equal(t, &pb.GetLivezResponse{Status: "OK", Code: 200}, resp)
}

func TestHealthService_GetReadyz_SpiceDBAvailable(t *testing.T) {
Expand All @@ -37,7 +37,7 @@ func TestHealthService_GetReadyz_SpiceDBAvailable(t *testing.T) {
resp, err := service.GetReadyz(ctx, &pb.GetReadyzRequest{})

assert.NoError(t, err)
assert.Equal(t, resp, &pb.GetReadyzResponse{Status: "OK", Code: 200})
assert.Equal(t, &pb.GetReadyzResponse{Status: "OK", Code: 200}, resp)
}

func TestHealthService_GetReadyz_SpiceDBUnavailable(t *testing.T) {
Expand All @@ -51,7 +51,7 @@ func TestHealthService_GetReadyz_SpiceDBUnavailable(t *testing.T) {
resp, err := service.GetReadyz(ctx, &pb.GetReadyzRequest{})

assert.NoError(t, err)
assert.Equal(t, resp, &pb.GetReadyzResponse{Status: "Unavailable", Code: 503})
assert.Equal(t, &pb.GetReadyzResponse{Status: "Unavailable", Code: 503}, resp)
}

func TestHealthService_GetReadyz_StillReadyAfterBackendLaterUnavailable(t *testing.T) {
Expand All @@ -64,19 +64,19 @@ func TestHealthService_GetReadyz_StillReadyAfterBackendLaterUnavailable(t *testi
resp, err := service.GetReadyz(ctx, &pb.GetReadyzRequest{})

assert.NoError(t, err)
assert.Equal(t, resp, &pb.GetReadyzResponse{Status: "Unavailable", Code: 503})
assert.Equal(t, &pb.GetReadyzResponse{Status: "Unavailable", Code: 503}, resp)

d.SetAvailable(true)
resp, err = service.GetReadyz(ctx, &pb.GetReadyzRequest{})

assert.NoError(t, err)
assert.Equal(t, resp, &pb.GetReadyzResponse{Status: "OK", Code: 200})
assert.Equal(t, &pb.GetReadyzResponse{Status: "OK", Code: 200}, resp)

d.SetAvailable(false)
resp, err = service.GetReadyz(ctx, &pb.GetReadyzRequest{})

assert.NoError(t, err)
assert.Equal(t, resp, &pb.GetReadyzResponse{Status: "OK", Code: 200})
assert.Equal(t, &pb.GetReadyzResponse{Status: "OK", Code: 200}, resp)
}

type DummyZanzibar struct {
Expand Down
4 changes: 2 additions & 2 deletions internal/service/relationships_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func TestRelationshipsService_CreateRelationshipsWithTouchFalse(t *testing.T) {
}

_, err = relationshipsService.CreateTuples(ctx, req)
assert.Equal(t, status.Convert(err).Code(), codes.AlreadyExists)
assert.Equal(t, codes.AlreadyExists, status.Convert(err).Code())

}

Expand Down Expand Up @@ -172,7 +172,7 @@ func TestRelationshipsService_CreateRelationshipsWithBadSubjectType(t *testing.T
}
_, err = relationshipsService.CreateTuples(ctx, req)
assert.Error(t, err)
assert.Equal(t, status.Convert(err).Code(), codes.FailedPrecondition)
assert.Equal(t, codes.FailedPrecondition, status.Convert(err).Code())
assert.Contains(t, err.Error(),
fmt.Sprintf("object definition `%s/%s` not found", badSubjectType.GetNamespace(), badSubjectType.GetName()))
}
Expand Down

0 comments on commit 5e351f0

Please sign in to comment.