github.com/palisadeinc/bor@v0.0.0-20230615125219-ab7196213d15/internal/cli/server/chains/chain_test.go (about) 1 package chains 2 3 import ( 4 "testing" 5 ) 6 7 func TestChain_ImportFromFile(t *testing.T) { 8 t.Parallel() 9 10 type args struct { 11 filename string 12 } 13 14 tests := []struct { 15 name string 16 args args 17 wantErr bool 18 }{ 19 { 20 name: "ImportFromFile correct json file", 21 args: args{filename: "test_files/chain_test.json"}, 22 wantErr: false, 23 }, 24 { 25 name: "ImportFromFile correct legacy json file", 26 args: args{filename: "test_files/chain_legacy_test.json"}, 27 wantErr: false, 28 }, 29 { 30 name: "ImportFromFile wrong json file", 31 args: args{filename: "test_files/wrong_chain.json"}, 32 wantErr: true, 33 }, 34 { 35 name: "ImportFromFile nonexistent json file", 36 args: args{filename: "test_files/chain_test_nonexistent.json"}, 37 wantErr: true, 38 }, 39 } 40 41 for _, tt := range tests { 42 tt := tt 43 44 t.Run(tt.name, func(t *testing.T) { 45 t.Parallel() 46 47 _, err := ImportFromFile(tt.args.filename) 48 if (err != nil) != tt.wantErr { 49 t.Errorf("ImportFromFile() error = %v, wantErr %v", err, tt.wantErr) 50 return 51 } 52 }) 53 } 54 }