Skip to content

Commit

Permalink
fix: Get failing postablePipeline tests to pass
Browse files Browse the repository at this point in the history
  • Loading branch information
raj-k-singh committed Jul 31, 2023
1 parent a6e3a30 commit ba23cc8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 6 additions & 2 deletions pkg/query-service/app/logparsingpipeline/postablePipeline.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package logparsingpipeline

import (
"errors"
"fmt"
"regexp"
"strings"
Expand Down Expand Up @@ -95,7 +96,9 @@ func (p *PostablePipeline) IsValid() error {
}

func isValidOperator(op model.PipelineOperator) error {
valueErrStr := "value should have prefix of body, attributes, resource"
if op.ID == "" {
return errors.New("PipelineOperator.ID is required.")
}

switch op.Type {
case "json_parser":
Expand Down Expand Up @@ -160,7 +163,8 @@ func isValidOperator(op model.PipelineOperator) error {
!isValidOtelValue(op.From) ||
!isValidOtelValue(op.To) ||
!isValidOtelValue(op.Field) {
return fmt.Errorf(fmt.Sprintf("%s for operator Id %s", valueErrStr, op.ID))
valueErrStr := "value should have prefix of body, attributes, resource"
return fmt.Errorf(fmt.Sprintf("%s for operator Id %s", valueErrStr, op.ID))
}
return nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ var correctQueriesTest = []struct {
Filter: "attributes.method == \"GET\"",
Config: []model.PipelineOperator{},
},
IsValid: false,
IsValid: true,
},
{
Name: "Invalid filter",
Expand All @@ -67,14 +67,15 @@ var correctQueriesTest = []struct {
Enabled: true,
Filter: "attributes.method == \"GET\"",
},
IsValid: false,
IsValid: true,
},
}

func TestIsValidPostablePipeline(t *testing.T) {
for _, test := range correctQueriesTest {
Convey(test.Name, t, func() {
err := test.Pipeline.IsValid()
t.Logf("Testing: %s\t err: %v", test.Name, err)
if test.IsValid {
So(err, ShouldBeNil)
} else {
Expand Down

0 comments on commit ba23cc8

Please sign in to comment.