forked from berty/berty
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testing_test.go
50 lines (42 loc) · 1.14 KB
/
testing_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package bertyprotocol
import (
"context"
"fmt"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"berty.tech/berty/v2/go/pkg/protocoltypes"
)
func TestClient_impl(t *testing.T) {
var _ Service = (*service)(nil)
var _ protocoltypes.ProtocolServiceServer = (*service)(nil)
}
func TestEmptyArgs(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
// initialize new client
client, err := New(ctx, Opts{})
require.NoError(t, err)
err = client.Close()
require.NoError(t, err)
}
func TestTestingProtocol(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
opts := TestingOpts{}
tp, cleanup := NewTestingProtocol(ctx, t, &opts, nil)
assert.NotNil(t, tp)
cleanup()
cancel()
}
func TestTestingProtocolWithMockedPeers(t *testing.T) {
for amount := 0; amount < 5; amount++ {
t.Run(fmt.Sprintf("%d-peers", amount), func(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
opts := TestingOpts{}
tp, cleanup := NewTestingProtocolWithMockedPeers(ctx, t, &opts, nil, amount)
assert.NotNil(t, tp)
cleanup()
cancel()
})
}
}