forked from ava-labs/avalanchego
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tests to assert 1 to 1 relation between struct and interface
- Loading branch information
1 parent
3e15952
commit 837c2f3
Showing
8 changed files
with
143 additions
and
0 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,17 @@ | ||
package admin | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
) | ||
|
||
func TestInterfaceStructOneToOne(t *testing.T) { | ||
// checks struct provides at least the methods signatures in the interface | ||
var _ Client = (*client)(nil) | ||
// checks interface and struct have the same number of methods | ||
clientType := reflect.TypeOf(&client{}) | ||
ClientType := reflect.TypeOf((*Client)(nil)).Elem() | ||
if clientType.NumMethod() != ClientType.NumMethod() { | ||
t.Fatalf("no 1 to 1 compliance between struct methods (%v) and interface methods (%v)", clientType.NumMethod(), ClientType.NumMethod()) | ||
} | ||
} |
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,17 @@ | ||
package health | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
) | ||
|
||
func TestInterfaceStructOneToOne(t *testing.T) { | ||
// checks struct provides at least the methods signatures in the interface | ||
var _ Client = (*client)(nil) | ||
// checks interface and struct have the same number of methods | ||
clientType := reflect.TypeOf(&client{}) | ||
ClientType := reflect.TypeOf((*Client)(nil)).Elem() | ||
if clientType.NumMethod() != ClientType.NumMethod() { | ||
t.Fatalf("no 1 to 1 compliance between struct methods (%v) and interface methods (%v)", clientType.NumMethod(), ClientType.NumMethod()) | ||
} | ||
} |
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,17 @@ | ||
package info | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
) | ||
|
||
func TestInterfaceStructOneToOne(t *testing.T) { | ||
// checks struct provides at least the methods signatures in the interface | ||
var _ Client = (*client)(nil) | ||
// checks interface and struct have the same number of methods | ||
clientType := reflect.TypeOf(&client{}) | ||
ClientType := reflect.TypeOf((*Client)(nil)).Elem() | ||
if clientType.NumMethod() != ClientType.NumMethod() { | ||
t.Fatalf("no 1 to 1 compliance between struct methods (%v) and interface methods (%v)", clientType.NumMethod(), ClientType.NumMethod()) | ||
} | ||
} |
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,17 @@ | ||
package ipcs | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
) | ||
|
||
func TestInterfaceStructOneToOne(t *testing.T) { | ||
// checks struct provides at least the methods signatures in the interface | ||
var _ Client = (*client)(nil) | ||
// checks interface and struct have the same number of methods | ||
clientType := reflect.TypeOf(&client{}) | ||
ClientType := reflect.TypeOf((*Client)(nil)).Elem() | ||
if clientType.NumMethod() != ClientType.NumMethod() { | ||
t.Fatalf("no 1 to 1 compliance between struct methods (%v) and interface methods (%v)", clientType.NumMethod(), ClientType.NumMethod()) | ||
} | ||
} |
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,17 @@ | ||
package keystore | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
) | ||
|
||
func TestInterfaceStructOneToOne(t *testing.T) { | ||
// checks struct provides at least the methods signatures in the interface | ||
var _ Client = (*client)(nil) | ||
// checks interface and struct have the same number of methods | ||
clientType := reflect.TypeOf(&client{}) | ||
ClientType := reflect.TypeOf((*Client)(nil)).Elem() | ||
if clientType.NumMethod() != ClientType.NumMethod() { | ||
t.Fatalf("no 1 to 1 compliance between struct methods (%v) and interface methods (%v)", clientType.NumMethod(), ClientType.NumMethod()) | ||
} | ||
} |
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,17 @@ | ||
package indexer | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
) | ||
|
||
func TestInterfaceStructOneToOne(t *testing.T) { | ||
// checks struct provides at least the methods signatures in the interface | ||
var _ Client = (*client)(nil) | ||
// checks interface and struct have the same number of methods | ||
clientType := reflect.TypeOf(&client{}) | ||
ClientType := reflect.TypeOf((*Client)(nil)).Elem() | ||
if clientType.NumMethod() != ClientType.NumMethod() { | ||
t.Fatalf("no 1 to 1 compliance between struct methods (%v) and interface methods (%v)", clientType.NumMethod(), ClientType.NumMethod()) | ||
} | ||
} |
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,24 @@ | ||
package avm | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
) | ||
|
||
func TestInterfaceStructOneToOne(t *testing.T) { | ||
// checks struct provides at least the methods signatures in the interface | ||
var _ Client = (*client)(nil) | ||
// checks interface and struct have the same number of methods | ||
clientType := reflect.TypeOf(&client{}) | ||
ClientType := reflect.TypeOf((*Client)(nil)).Elem() | ||
if clientType.NumMethod() != ClientType.NumMethod() { | ||
t.Fatalf("no 1 to 1 compliance between struct methods (%v) and interface methods (%v)", clientType.NumMethod(), ClientType.NumMethod()) | ||
} | ||
// Wallet | ||
var _ WalletClient = (*walletClient)(nil) | ||
clientType = reflect.TypeOf(&walletClient{}) | ||
ClientType = reflect.TypeOf((*WalletClient)(nil)).Elem() | ||
if clientType.NumMethod() != ClientType.NumMethod() { | ||
t.Fatalf("no 1 to 1 compliance between struct methods (%v) and interface methods (%v)", clientType.NumMethod(), ClientType.NumMethod()) | ||
} | ||
} |
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,17 @@ | ||
package platformvm | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
) | ||
|
||
func TestInterfaceStructOneToOne(t *testing.T) { | ||
// checks struct provides at least the methods signatures in the interface | ||
var _ Client = (*client)(nil) | ||
// checks interface and struct have the same number of methods | ||
clientType := reflect.TypeOf(&client{}) | ||
ClientType := reflect.TypeOf((*Client)(nil)).Elem() | ||
if clientType.NumMethod() != ClientType.NumMethod() { | ||
t.Fatalf("no 1 to 1 compliance between struct methods (%v) and interface methods (%v)", clientType.NumMethod(), ClientType.NumMethod()) | ||
} | ||
} |