gmessages/libgm/events/ready_test.go

33 lines
1.1 KiB
Go
Raw Normal View History

2023-09-04 11:25:28 +00:00
package events_test
import (
"encoding/base64"
2023-09-04 11:31:59 +00:00
"fmt"
2023-09-04 11:25:28 +00:00
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.mau.fi/mautrix-gmessages/libgm/events"
"go.mau.fi/mautrix-gmessages/libgm/gmproto"
"go.mau.fi/mautrix-gmessages/libgm/pblite"
)
func TestRequestError_Is(t *testing.T) {
dat, _ := base64.StdEncoding.DecodeString("WzUsIlJlcXVlc3RlZCBlbnRpdHkgd2FzIG5vdCBmb3VuZC4iLFtbInR5cGUuZ29vZ2xlYXBpcy5jb20vZ29vZ2xlLmludGVybmFsLmNvbW11bmljYXRpb25zLmluc3RhbnRtZXNzYWdpbmcudjEuVGFjaHlvbkVycm9yIixbMV1dXV0=")
var errResp gmproto.ErrorResponse
err := pblite.Unmarshal(dat, &errResp)
require.NoError(t, err)
assert.ErrorIs(t, events.RequestError{Data: &errResp}, events.ErrRequestedEntityNotFound)
2023-09-04 11:31:59 +00:00
assert.ErrorIs(t, events.RequestError{Data: &errResp}, fmt.Errorf("meow: %w", events.ErrRequestedEntityNotFound))
2023-09-04 11:25:28 +00:00
assert.NotErrorIs(t, events.RequestError{Data: &errResp}, events.RequestError{
Data: &gmproto.ErrorResponse{
Type: 5,
Message: "meow.",
Class: []*gmproto.ErrorResponse_ErrorClass{{
Class: "type.googleapis.com/google.internal.communications.instantmessaging.v1.TachyonError",
}},
},
})
}