Skip to content

Commit

Permalink
add and update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kush-elastic committed Dec 26, 2023
1 parent 16d8c31 commit e19ee20
Show file tree
Hide file tree
Showing 5 changed files with 491 additions and 69 deletions.
1 change: 0 additions & 1 deletion x-pack/filebeat/input/salesforce/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ type config struct {
EventMonitoringMethod *EventMonitoringMethod `config:"event_monitoring_method"`
URL string `config:"url" validate:"required"`
Version int `config:"version" validate:"required"`
InitialInterval time.Duration `config:"initial_interval"`
}

type EventMonitoringMethod struct {
Expand Down
2 changes: 1 addition & 1 deletion x-pack/filebeat/input/salesforce/config_auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestOAuth2Config(t *testing.T) {
"tokenURL missing": {config: UserPasswordFlow{Enabled: pointer(true), TokenURL: ""}, wantErr: errors.New("token_url must be provided")},
"clientID missing": {config: UserPasswordFlow{Enabled: pointer(true), TokenURL: "https://salesforce.com", ClientID: ""}, wantErr: errors.New("client.id must be provided")},
"clientSecret missing": {config: UserPasswordFlow{Enabled: pointer(true), TokenURL: "https://salesforce.com", ClientID: "xyz", ClientSecret: ""}, wantErr: errors.New("client.secret must be provided")},
"user missing": {config: UserPasswordFlow{Enabled: pointer(true), TokenURL: "https://salesforce.com", ClientID: "xyz", ClientSecret: "abc", Username: ""}, wantErr: errors.New("username must be provided")},
"username missing": {config: UserPasswordFlow{Enabled: pointer(true), TokenURL: "https://salesforce.com", ClientID: "xyz", ClientSecret: "abc", Username: ""}, wantErr: errors.New("username must be provided")},
"password missing": {config: UserPasswordFlow{Enabled: pointer(true), TokenURL: "https://salesforce.com", ClientID: "xyz", ClientSecret: "abc", Username: "user", Password: ""}, wantErr: errors.New("password must be provided")},
"all present": {config: UserPasswordFlow{Enabled: pointer(true), TokenURL: "https://salesforce.com", ClientID: "xyz", ClientSecret: "abc", Username: "user", Password: "pass"}, wantErr: nil},
}
Expand Down
4 changes: 2 additions & 2 deletions x-pack/filebeat/input/salesforce/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func (s *salesforceInput) SetupSFClientConnection() (*soql.Resource, error) {

// FormQueryWithCursor takes a queryConfig and a cursor and returns a querier.
func (s *salesforceInput) FormQueryWithCursor(queryConfig *QueryConfig, cursor mapstr.M) (*querier, error) {
qr, err := parseCursor(&s.config.InitialInterval, queryConfig, cursor, s.log)
qr, err := parseCursor(queryConfig, cursor, s.log)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -306,7 +306,7 @@ func (s *salesforceInput) RunEventLogFile() error {
totalEvents, firstEvent := 0, true
for res.Done() {
for _, rec := range res.Records() {
req, err := http.NewRequestWithContext(s.ctx, "GET", s.config.URL+rec.Record().Fields()["LogFile"].(string), nil)
req, err := http.NewRequestWithContext(s.ctx, http.MethodGet, s.config.URL+rec.Record().Fields()["LogFile"].(string), nil)
if err != nil {
return err
}
Expand Down
Loading

0 comments on commit e19ee20

Please sign in to comment.