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

ShouldResemble failing for identical values in GitHub action #665

Open
sb10 opened this issue Aug 12, 2022 · 2 comments
Open

ShouldResemble failing for identical values in GitHub action #665

sb10 opened this issue Aug 12, 2022 · 2 comments

Comments

@sb10
Copy link

sb10 commented Aug 12, 2022

Using go 1.19 (also happened with go 1.18) and goconvey v1.7.2 both locally and in a GitHub action, my tests pass locally but fail in GitHub:

https://github.com/wtsi-ssg/wrstat/runs/7804713143?check_suite_focus=true

Failures:
[144](https://github.com/wtsi-ssg/wrstat/runs/7804713143?check_suite_focus=true#step:4:145)

[145](https://github.com/wtsi-ssg/wrstat/runs/7804713143?check_suite_focus=true#step:4:146)
  * /home/runner/work/wrstat/wrstat/server/server_test.go 
[146](https://github.com/wtsi-ssg/wrstat/runs/7804713143?check_suite_focus=true#step:4:147)
  Line 450:
[147](https://github.com/wtsi-ssg/wrstat/runs/7804713143?check_suite_focus=true#step:4:148)
  Expected: '[]*server.DirSummary{(*server.DirSummary){Dir:"/a", Count:15, Size:86, Atime:time.Time{1970-01-01 00:00:50 +0000 UTC}, Users:[]string{"root", "runner"}, Groups:[]string{"adm", "docker", "root"}, FileTypes:[]string{"bam", "cram", "temporary"}}, (*server.DirSummary){Dir:"/a/b", Count:9, Size:80, Atime:time.Time{1970-01-01 00:00:50 +0000 UTC}, Users:[]string{"root", "runner"}, Groups:[]string{"docker"}, FileTypes:[]string{"bam", "cram", "temporary"}}, (*server.DirSummary){Dir:"/a/b/d", Count:7, Size:70, Atime:time.Time{1970-01-01 00:00:50 +0000 UTC}, Users:[]string{"root", "runner"}, Groups:[]string{"docker"}, FileTypes:[]string{"cram"}}, (*server.DirSummary){Dir:"/a/b/e/h", Count:2, Size:10, Atime:time.Time{1970-01-01 00:00:50 +0000 UTC}, Users:[]string{"runner"}, Groups:[]string{"docker"}, FileTypes:[]string{"bam", "temporary"}}, (*server.DirSummary){Dir:"/a/c/d", Count:5, Size:5, Atime:time.Time{1970-01-01 00:00:50 +0000 UTC}, Users:[]string{"root"}, Groups:[]string{"adm"}, FileTypes:[]string{"cram"}}}'
[148](https://github.com/wtsi-ssg/wrstat/runs/7804713143?check_suite_focus=true#step:4:149)
  Actual:   '[]*server.DirSummary{(*server.DirSummary){Dir:"/a", Count:15, Size:86, Atime:time.Time{1970-01-01 00:00:50 +0000 UTC}, Users:[]string{"root", "runner"}, Groups:[]string{"adm", "docker", "root"}, FileTypes:[]string{"bam", "cram", "temporary"}}, (*server.DirSummary){Dir:"/a/b", Count:9, Size:80, Atime:time.Time{1970-01-01 00:00:50 +0000 UTC}, Users:[]string{"root", "runner"}, Groups:[]string{"docker"}, FileTypes:[]string{"bam", "cram", "temporary"}}, (*server.DirSummary){Dir:"/a/b/d", Count:7, Size:70, Atime:time.Time{1970-01-01 00:00:50 +0000 UTC}, Users:[]string{"root", "runner"}, Groups:[]string{"docker"}, FileTypes:[]string{"cram"}}, (*server.DirSummary){Dir:"/a/b/e/h", Count:2, Size:10, Atime:time.Time{1970-01-01 00:00:50 +0000 UTC}, Users:[]string{"runner"}, Groups:[]string{"docker"}, FileTypes:[]string{"bam", "temporary"}}, (*server.DirSummary){Dir:"/a/c/d", Count:5, Size:5, Atime:time.Time{1970-01-01 00:00:50 +0000 UTC}, Users:[]string{"root"}, Groups:[]string{"adm"}, FileTypes:[]string{"cram"}}}'
[149](https://github.com/wtsi-ssg/wrstat/runs/7804713143?check_suite_focus=true#step:4:150)
  (Should resemble)!
[150](https://github.com/wtsi-ssg/wrstat/runs/7804713143?check_suite_focus=true#step:4:151)
  Diff:     '[]*server.DirSummary{(*server.DirSummary){Dir:"/a", Count:15, Size:86, Atime:time.Time{1970-01-01 00:00:50 +0000 UTC}, Users:[]string{"root", "runner"}, Groups:[]string{"adm", "docker", "root"}, FileTypes:[]string{"bam", "cram", "temporary"}}, (*server.DirSummary){Dir:"/a/b", Count:9, Size:80, Atime:time.Time{1970-01-01 00:00:50 +0000 UTC}, Users:[]string{"root", "runner"}, Groups:[]string{"docker"}, FileTypes:[]string{"bam", "cram", "temporary"}}, (*server.DirSummary){Dir:"/a/b/d", Count:7, Size:70, Atime:time.Time{1970-01-01 00:00:50 +0000 UTC}, Users:[]string{"root", "runner"}, Groups:[]string{"docker"}, FileTypes:[]string{"cram"}}, (*server.DirSummary){Dir:"/a/b/e/h", Count:2, Size:10, Atime:time.Time{1970-01-01 00:00:50 +0000 UTC}, Users:[]string{"runner"}, Groups:[]string{"docker"}, FileTypes:[]string{"bam", "temporary"}}, (*server.DirSummary){Dir:"/a/c/d", Count:5, Size:5, Atime:time.Time{1970-01-01 00:00:50 +0000 UTC}, Users:[]string{"root"}, Groups:[]string{"adm"}, FileTypes:[]string{"cram"}}}'

You will note that the "Expected" and "Actual" strings that it prints out are actually identical.

Why would this be happening, and what can I do about it?

@sb10
Copy link
Author

sb10 commented Aug 12, 2022

After a bit of debugging, it looks like when you defer to reflect.DeepEqual, it's returning false. So not your "fault", but the message returned is confusing.

Why isn't ShouldResemble implemented by doing something like:

renderedExpected, renderedActual := render.Render(expected[0]), render.Render(actual)
if renderedExpected != renderedActual {
   ...
}

@srabraham
Copy link
Contributor

I just encountered what I think is the same issue. It happens when two different int types are compared.

func TestSillyDiff(t *testing.T) {
	type value struct {
		v any
	}
	v1 := value{int(123)}
	v2 := value{int64(123)}
	Convey("These things ain't the same", t, func() {
		// this passes
		So(reflect.DeepEqual(v1, v2), ShouldBeFalse)
		// this fails, see message below this block
		So(v1, ShouldResemble, v2)
	})
}

the above prints something like this, which is technically true, but the diff is useless

  Line 28:
  Expected: 'pkg.value{v:123}'
  Actual:   'pkg.value{v:123}'
  (Should resemble)!
  Diff:     'pkg.value{v:123}'

srabraham added a commit to srabraham/smartystreets-assertions that referenced this issue Apr 3, 2023
Currently ShouldResemble fails confusingly when the visual diff of
two items is the same despite DeepEquals being false.

See more context in comments in the PR, or at these issues
smarty#50
smartystreets/goconvey#665
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