This repository has been archived by the owner on Sep 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
627 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package ethereum | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/smartcontractkit/external-initiator/store" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func Test_createManager(t *testing.T) { | ||
rpcSub := store.Subscription{Job: "1234-rpc", Endpoint: store.Endpoint{Url: "https://example.com"}} | ||
rpcManager, err := createManager(rpcSub) | ||
require.NoError(t, err) | ||
|
||
type args struct { | ||
sub store.Subscription | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
want *manager | ||
wantErr bool | ||
}{ | ||
{ | ||
"creates manager with RPC subscriber", | ||
args{rpcSub}, | ||
rpcManager, | ||
false, | ||
}, | ||
{ | ||
"fails with invalid URL scheme", | ||
args{store.Subscription{Job: "1234-invalid-url", Endpoint: store.Endpoint{Url: "not valid"}}}, | ||
nil, | ||
true, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
got, err := createManager(tt.args.sub) | ||
if (err != nil) != tt.wantErr { | ||
t.Errorf("createManager() error = %v, wantErr %v", err, tt.wantErr) | ||
return | ||
} | ||
if tt.want != nil && got == nil { | ||
t.Errorf("createManager() got nil") | ||
return | ||
} | ||
if got != nil && tt.want.subscriber.Type() != got.subscriber.Type() { | ||
t.Errorf("createManager() got Type() = %v, want %v", got.subscriber.Type(), tt.want.subscriber.Type()) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.