ory / dockertest

Write better integration tests! Dockertest helps you boot up ephermal docker images for your Go tests with minimal work.
https://www.ory.sh/?utm_source=github&utm_medium=banner&utm_campaign=dockertest
Apache License 2.0
4.1k stars 243 forks source link

Failure to Validate Error for Violated Foreign Key Constraints #491

Closed Lapakin closed 7 months ago

Lapakin commented 7 months ago

Preflight checklist

Ory Network Project

No response

Describe the bug

An incorrect result is recorded during the execution of a test scenario that involves detecting the ViolatedForeignKey error: `message: "Duplicate unique value error in table members: Key (user_id)=(0) already exists.'. However, this result is inappropriate for the situation, since there is no user with the specified identifier (user_id=0). In the normal mode, the error is worked out image

Reproducing the bug

  1. go test integration_test.go

Relevant log output

--- FAIL: TestCreateMembers (0.01s)
    --- FAIL: TestCreateMembers/ViolatedForeignKeyError (0.00s)
        integration_test.go:213: 
                Error Trace:    /integration-test/integration_test.go:213
                Error:          Not equal: 
                                expected: 404
                                actual  : 400
                Test:           TestCreateMembers/ViolatedForeignKeyError
        integration_test.go:214: 
                Error Trace:    /integration-test/integration_test.go:214
                Error:          Not equal: 
                                expected: "{\"code\":404,\"message\":\"Foreign key violation value error in table : \"}"
                                actual  : "{\"code\":400,\"message\":\"Duplicate unique value error in table members: Key (user_id)=(0) already exists.\"}"

                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -1 +1 @@
                                -{"code":404,"message":"Foreign key violation value error in table : "}
                                +{"code":400,"message":"Duplicate unique value error in table members: Key (user_id)=(0) already exists."}
                Test:           TestCreateMembers/ViolatedForeignKeyError
FAIL
FAIL    command-line-arguments  2.782s
FAIL

Relevant configuration

Repository: "postgres",
        Tag:        "",
        Env: []string{
            "POSTGRES_USER=admin",
            "POSTGRES_PASSWORD=***",
            "POSTGRES_DB=user-management",
            "listen_addresses = '*'",

Version

v3.3.5+incompatible

On which operating system are you observing this issue?

Linux

In which environment are you deploying?

Other

Additional Context

Before the test, two users with user_id 1000 and 1001 were initialized using test assemblies. Therefore, it is unclear why an error would occur with an identifier that is not in this range.