Skip to content

Commit

Permalink
(test): Add Test for ValidateGenerators func
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinGimbel committed May 15, 2017
1 parent 6fe5c03 commit ea8808a
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions pkg/fakedata/fakedata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,28 @@ func TestGenerateRowWithEnum(t *testing.T) {
})
}
}

func TestValidateGenerators(t *testing.T) {
type args struct {
keys []string
}
tests := []struct {
name string
args args
wantErr bool
}{
{"known generator", args{keys: []string{"email", "domain"}}, false},
{"unknown generator", args{keys: []string{"nogen"}}, true},
{"mixed generators", args{keys: []string{"nogen", "email", "domain"}}, true},
{"generator with arguments", args{keys: []string{"int,1..100"}}, false},
{"mixed generator with arguments", args{keys: []string{"int,1..100", "domain", "email"}}, false},
{"mixed unknwon generator with arguments", args{keys: []string{"int,1..100", "salery,10k..100k", "email"}}, true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := fakedata.ValidateGenerators(tt.args.keys); (err != nil) != tt.wantErr {
t.Errorf("ValidateKeys() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}

0 comments on commit ea8808a

Please sign in to comment.