1. 3

  2. 1

    The workaround is to use PartialEqual for non-zero values, and standard assertions for zero ones.

    Does this not just bring you right back where new fields in a struct aren’t being checked? I’m not a Go developer, but this seems more explicit to me:

    result := foo.GetResult()
    expected := foo.Result{
        foo: 2,
        bar: nil,
        // There is also a CreatedAt and UpdatedAt field, but we ignore them
    equal_struct(t, result, expected, "CreatedAt", "UpdatedAt")

    equal_struct then checks that the foo and bar fields are the same, ignores CreatedAt and UpdatedAt, and then makes sure there are no more fields.

    1. 1

      I’m curious about the implementation of PartialEqual… but I don’t see a link to the source code? I would love to compare it to gstruct from GoMega https://onsi.github.io/gomega/#codegstructcode-testing-complex-data-types

      1. 1