mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-28 15:46:43 +00:00
Add test case for Import from file
This commit is contained in:
parent
b3984096e2
commit
d7ebe2fca1
2 changed files with 128 additions and 0 deletions
36
internal/cli/server/chains/chain_test.go
Normal file
36
internal/cli/server/chains/chain_test.go
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
package chains
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestImportFromFile(t *testing.T) {
|
||||
type args struct {
|
||||
filename string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "ImportFromFile correct json file",
|
||||
args: args{filename: "test_files/chain_test.json"},
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "ImportFromFile nonexistent json file",
|
||||
args: args{filename: "test_files/chain_test_nonexistent.json"},
|
||||
wantErr: true,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
_, err := ImportFromFile(tt.args.filename)
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("ImportFromFile() error = %v, wantErr %v", err, tt.wantErr)
|
||||
return
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
92
internal/cli/server/chains/test_files/chain_test.json
Normal file
92
internal/cli/server/chains/test_files/chain_test.json
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue