Skip to content

Commit

Permalink
using testify instead of testing.T methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
kehiy committed Sep 8, 2024
1 parent 8ec7f41 commit 26c61ce
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
6 changes: 3 additions & 3 deletions envelopes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestNoticeEnvelopeEncodingAndDecoding(t *testing.T) {
var env NoticeEnvelope
err := json.Unmarshal([]byte(noticeEnv), &env)
assert.NoError(t, err)
assert.Equal(t, "kjasbdlasvdluiasvd\"kjasbdksab\\d", env)
assert.Equal(t, "kjasbdlasvdluiasvd\"kjasbdksab\\d", string(env))

res, err := json.Marshal(env)
assert.NoError(t, err)
Expand All @@ -45,7 +45,7 @@ func TestEoseEnvelopeEncodingAndDecoding(t *testing.T) {
var env EOSEEnvelope
err := json.Unmarshal([]byte(eoseEnv), &env)
assert.NoError(t, err)
assert.Equal(t, "kjasbdlasvdluiasvd\"kjasbdksab\\d", env)
assert.Equal(t, "kjasbdlasvdluiasvd\"kjasbdksab\\d", string(env))

res, err := json.Marshal(env)
assert.NoError(t, err)
Expand All @@ -57,7 +57,7 @@ func TestCountEnvelopeEncodingAndDecoding(t *testing.T) {
var env CountEnvelope
err := json.Unmarshal([]byte(countEnv), &env)
assert.NoError(t, err)
assert.Equal(t, 12, *env.Count)
assert.Equal(t, int64(12), *env.Count)

res, err := json.Marshal(env)
assert.NoError(t, err)
Expand Down
4 changes: 3 additions & 1 deletion eose_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ func TestEOSEMadness(t *testing.T) {
n++
case <-sub.EndOfStoredEvents:
e++
assert.Less(t, e, 1, "eose infinite loop")
assert.Condition(t, func() (success bool) {
return !(e > 1)
}, "eose infinite loop")
continue
case <-rl.Context().Done():
t.Fatalf("connection closed: %v", rl.Context().Err())
Expand Down
8 changes: 5 additions & 3 deletions relay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func TestPublishBlocked(t *testing.T) {
// connect a client and send a text note
rl := mustRelayConnect(t, ws.URL)
err := rl.Publish(context.Background(), textNote)
assert.NoError(t, err)
assert.Error(t, err)
}

func TestPublishWriteFailed(t *testing.T) {
Expand All @@ -100,7 +100,7 @@ func TestPublishWriteFailed(t *testing.T) {
// Force brief period of time so that publish always fails on closed socket.
time.Sleep(1 * time.Millisecond)
err := rl.Publish(context.Background(), textNote)
assert.NoError(t, err)
assert.Error(t, err)
}

func TestConnectContext(t *testing.T) {
Expand Down Expand Up @@ -195,7 +195,9 @@ func mustRelayConnect(t *testing.T, url string) *Relay {
func parseEventMessage(t *testing.T, raw []json.RawMessage) Event {
t.Helper()

assert.Greater(t, len(raw), 2)
assert.Condition(t, func() (success bool) {
return len(raw) >= 2
})

var typ string
err := json.Unmarshal(raw[0], &typ)
Expand Down

0 comments on commit 26c61ce

Please sign in to comment.