Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TestDiff/mixed-slice-map fails randomly #95

Open
zhsj opened this issue Jan 19, 2023 · 1 comment
Open

TestDiff/mixed-slice-map fails randomly #95

zhsj opened this issue Jan 19, 2023 · 1 comment

Comments

@zhsj
Copy link

zhsj commented Jan 19, 2023

=== RUN   TestDiff/mixed-slice-map
    diff_test.go:645: 
                Error Trace:    diff_test.go:645
                Error:          Not equal: 
                                expected: []string{"1", "\xa4name"}
                                actual  : []string{"1", "\xa4type"}
                            
                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -2,3 +2,3 @@
                                  (string) (len=1) "1",
                                - (string) (len=5) "\xa4name"
                                + (string) (len=5) "\xa4type"
                                 }
                Test:           TestDiff/mixed-slice-map
    diff_test.go:647: 
                Error Trace:    diff_test.go:647
                Error:          Not equal: 
                                expected: string("name2")
                                actual  : []string([]string{"null", "string"})
                Test:           TestDiff/mixed-slice-map
    diff_test.go:645: 
                Error Trace:    diff_test.go:645
                Error:          Not equal: 
                                expected: []string{"1", "\xa4type"}
                                actual  : []string{"1", "\xa4name"}
                            
                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -2,3 +2,3 @@
                                  (string) (len=1) "1",
                                - (string) (len=5) "\xa4type"
                                + (string) (len=5) "\xa4name"
                                 }
                Test:           TestDiff/mixed-slice-map
    diff_test.go:647: 
                Error Trace:    diff_test.go:647
                Error:          Not equal: 
                                expected: []string([]string{"null", "string"})
                                actual  : string("name2")
                Test:           TestDiff/mixed-slice-map

It can be reproduced by run go test -count=10

@teran
Copy link

teran commented May 18, 2024

Hello,

I've probably got something similar with diff'ing map[string]map[string]string

teran added a commit to runityru/cephctl that referenced this issue May 18, 2024
Sometimes tests could fail because of improper changelong result on
complex structures like `map[string]map[string]string`.

Now diff functionality is wrapped and this use case is worked around via
flattening the structure.

Ref: r3labs/diff#95

Signed-off-by: Igor Shishkin <me@teran.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants