Created
May 25, 2017 12:45
-
-
Save christo4ferris/6c15df8c135b9986a158203d5e635313 to your computer and use it in GitHub Desktop.
common_test
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
var mspdir, _ = config.GetDevMspDir() | |
func TestInitConfig(t *testing.T) { | |
type args struct { | |
cmdRoot string | |
} | |
tests := []struct { | |
name string | |
args args | |
wantErr bool | |
}{ | |
{ | |
name: "Empty command root", | |
args: args{cmdRoot: ""}, | |
wantErr: true, | |
}, | |
{ | |
name: "Bad command root", | |
args: args{cmdRoot: "cre"}, | |
wantErr: true, | |
}, | |
{ | |
name: "Good command root", | |
args: args{cmdRoot: "core"}, | |
wantErr: false, | |
}, | |
} | |
for _, tt := range tests { | |
t.Run(tt.name, func(t *testing.T) { | |
if err := InitConfig(tt.args.cmdRoot); (err != nil) != tt.wantErr { | |
t.Errorf("InitConfig() error = %v, wantErr %v", err, tt.wantErr) | |
} | |
}) | |
} | |
} | |
func TestInitCrypto(t *testing.T) { | |
//t.Skip("Needs more initialization") | |
type args struct { | |
mspMgrConfigDir string | |
localMSPID string | |
} | |
tests := []struct { | |
name string | |
args args | |
wantErr bool | |
}{ | |
{ | |
name: "Empty mspMgrConfigDir", | |
args: args{ | |
mspMgrConfigDir: "", | |
localMSPID: "cre", | |
}, | |
wantErr: true, | |
}, | |
{ | |
name: "Bad mspMgrConfigDir", | |
args: args{ | |
mspMgrConfigDir: "cre", | |
localMSPID: "cre", | |
}, | |
wantErr: true, | |
}, | |
{ | |
name: "Bad localMSPID", | |
args: args{ | |
mspMgrConfigDir: "msp", | |
localMSPID: "cre", | |
}, | |
wantErr: true, | |
}, | |
{ | |
name: "Good mspMgrConfigDir and localMSPID", | |
args: args{ | |
mspMgrConfigDir: mspdir, | |
localMSPID: viper.GetString("peer.localMspId"), | |
}, | |
wantErr: false, | |
}, | |
} | |
for _, tt := range tests { | |
t.Run(tt.name, func(t *testing.T) { | |
if err := InitCrypto(tt.args.mspMgrConfigDir, tt.args.localMSPID); (err != nil) != tt.wantErr { | |
t.Errorf("InitCrypto() args = %v error = %v, wantErr %v", tt.args, err, tt.wantErr) | |
} | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment