Stanislav Vodetskyi
11/19/2024, 8:54 PMGetUserResponse
contains non-nil user
field and nil error
field, but it's probably not ok if both are nil (but it's likely ok if both are non-nil)?rholshausen
11/19/2024, 10:32 PMStanislav Vodetskyi
11/19/2024, 10:39 PMrholshausen
11/19/2024, 10:42 PMStanislav Vodetskyi
11/19/2024, 11:29 PMuser, err := userService.GetUser()
// skip err
if user == nil {
// user itself can be nil
// but user.GetID() would return default value
user.GetID()
}
I do see in some of our services we do have nil checks for message fields. Is it implemented differently in rust?Stanislav Vodetskyi
11/19/2024, 11:32 PMfunc (m *User) GetEmail() string {
if m != nil {
return m.Email
}
return ""
}
and here's one for the message type (default value is nil):
func (m *User) GetCreated() *types.Timestamp {
if m != nil {
return m.Created
}
return nil
}
rholshausen
11/19/2024, 11:37 PMStanislav Vodetskyi
11/19/2024, 11:48 PM"msg": {
"pact:match": "notEmpty($'_msg_template')",
"_msg_template": {
"username": "matching(type, 'user')",
// etc
}
}
but it didn't work (of course)Stanislav Vodetskyi
11/19/2024, 11:49 PM"msg": "notEmpty()"
to hopefully just trigger the non-nil check, but its also not supportedrholshausen
11/19/2024, 11:53 PMrholshausen
11/19/2024, 11:55 PMStanislav Vodetskyi
11/20/2024, 12:01 AMmessage GetUserReply {
User user = 1;
Info info = 2;
Data data = 3;
Error error = 4;
}
and I have matchers defined on all the fields, and the server responded with a message where User
is defined but data, info and error are nil, the provider test still passed.
I'll try to provide a reproducible case some time this week.Stanislav Vodetskyi
11/20/2024, 12:24 AMnotEmpty
for some fields inside e.g. user
rholshausen
11/20/2024, 12:27 AMStanislav Vodetskyi
11/20/2024, 12:41 AM