github.com/aergoio/aergo@v1.3.1/polaris/server/genesisreader_test.go (about)

     1  /*
     2   * @file
     3   * @copyright defined in aergo/LICENSE.txt
     4   */
     5  
     6  package server
     7  
     8  import (
     9  	"testing"
    10  
    11  	"github.com/aergoio/aergo/types"
    12  )
    13  
    14  func Test_readGenesis(t *testing.T) {
    15  	sampleGenesis := &types.Genesis{}
    16  
    17  	type args struct {
    18  		filePath string
    19  	}
    20  	tests := []struct {
    21  		name    string
    22  		args    args
    23  		wantRet *types.Genesis
    24  		wantErr bool
    25  	}{
    26  		{"Tsucc", args{"../../examples/genesis.json"}, sampleGenesis, false },
    27  		{"TNotExist", args{"../../examples/genesis.notjson"}, nil, true},
    28  		{"TNotGenesis", args{"../../examples/component/main.go"}, nil, true},
    29  		// TODO: Add test cases.
    30  	}
    31  	for _, tt := range tests {
    32  		t.Run(tt.name, func(t *testing.T) {
    33  			gotRet, err := readGenesis(tt.args.filePath)
    34  			if (err != nil) != tt.wantErr {
    35  				t.Errorf("readGenesis() error = %v, wantErr %v", err, tt.wantErr)
    36  				return
    37  			}
    38  
    39  			//if !reflect.DeepEqual(gotRet, tt.wantRet) {
    40  			//	t.Errorf("readGenesis() = %v, want %v", gotRet, tt.wantRet)
    41  			//}
    42  			if (tt.wantRet == nil) != (gotRet == nil) {
    43  				t.Errorf("readGenesis() = %v, want %v", gotRet, tt.wantRet)
    44  			}
    45  		})
    46  	}
    47  }