diff --git a/test/utils/directory.go b/test/utils/directory.go index 47ba6cb3..b3eed52f 100644 --- a/test/utils/directory.go +++ b/test/utils/directory.go @@ -9,6 +9,8 @@ import ( utils_file "github.com/flant/shell-operator/pkg/utils/file" ) +// TODO: remove useless code + // ChooseExistedDirectoryPath returns first non-empty existed directory path from arguments. // // Each argument is prefixed with current directory if is not started with / diff --git a/test/utils/jqmatcher.go b/test/utils/jqmatcher.go index 5d6ab415..6e9f64ee 100644 --- a/test/utils/jqmatcher.go +++ b/test/utils/jqmatcher.go @@ -1,66 +1,68 @@ //go:build test // +build test +// TODO: remove useless code + package utils -import ( - "encoding/json" - "fmt" +// import ( +// "encoding/json" +// "fmt" - "github.com/onsi/gomega/matchers" - "github.com/onsi/gomega/types" +// "github.com/onsi/gomega/matchers" +// "github.com/onsi/gomega/types" - . "github.com/flant/libjq-go" -) +// . "github.com/flant/libjq-go" +// ) -// var _ = Ω(verBcs).To(MatchJq(`.[0] | has("objects")`, Equal(true))) -func MatchJq(jqExpression string, matcher interface{}) types.GomegaMatcher { - return &matchJq{ - JqExpr: jqExpression, - Matcher: matcher, - } -} +// // var _ = Ω(verBcs).To(MatchJq(`.[0] | has("objects")`, Equal(true))) +// func MatchJq(jqExpression string, matcher interface{}) types.GomegaMatcher { +// return &matchJq{ +// JqExpr: jqExpression, +// Matcher: matcher, +// } +// } -type matchJq struct { - JqExpr string - InputString string - Matcher interface{} - ResMatcher types.GomegaMatcher -} +// type matchJq struct { +// JqExpr string +// InputString string +// Matcher interface{} +// ResMatcher types.GomegaMatcher +// } -func (matcher *matchJq) Match(actual interface{}) (success bool, err error) { - switch v := actual.(type) { - case string: - matcher.InputString = v - case []byte: - matcher.InputString = string(v) - default: - inputBytes, err := json.Marshal(v) - if err != nil { - return false, fmt.Errorf("MatchJq marshal object to json: %s\n", err) - } - matcher.InputString = string(inputBytes) - } +// func (matcher *matchJq) Match(actual interface{}) (success bool, err error) { +// switch v := actual.(type) { +// case string: +// matcher.InputString = v +// case []byte: +// matcher.InputString = string(v) +// default: +// inputBytes, err := json.Marshal(v) +// if err != nil { +// return false, fmt.Errorf("MatchJq marshal object to json: %s\n", err) +// } +// matcher.InputString = string(inputBytes) +// } - //nolint:typecheck // Ignore false positive: undeclared name: `Jq`. - res, err := Jq().Program(matcher.JqExpr).Run(matcher.InputString) - if err != nil { - return false, fmt.Errorf("MatchJq apply jq expression: %s\n", err) - } +// //nolint:typecheck // Ignore false positive: undeclared name: `Jq`. +// res, err := Jq().Program(matcher.JqExpr).Run(matcher.InputString) +// if err != nil { +// return false, fmt.Errorf("MatchJq apply jq expression: %s\n", err) +// } - var isMatcher bool - matcher.ResMatcher, isMatcher = matcher.Matcher.(types.GomegaMatcher) - if !isMatcher { - matcher.ResMatcher = &matchers.EqualMatcher{Expected: res} - } +// var isMatcher bool +// matcher.ResMatcher, isMatcher = matcher.Matcher.(types.GomegaMatcher) +// if !isMatcher { +// matcher.ResMatcher = &matchers.EqualMatcher{Expected: res} +// } - return matcher.ResMatcher.Match(res) -} +// return matcher.ResMatcher.Match(res) +// } -func (matcher *matchJq) FailureMessage(actual interface{}) (message string) { - return fmt.Sprintf("Jq expression `%s` applied to '%s' not match: %v", matcher.JqExpr, matcher.InputString, matcher.ResMatcher.FailureMessage(actual)) -} +// func (matcher *matchJq) FailureMessage(actual interface{}) (message string) { +// return fmt.Sprintf("Jq expression `%s` applied to '%s' not match: %v", matcher.JqExpr, matcher.InputString, matcher.ResMatcher.FailureMessage(actual)) +// } -func (matcher *matchJq) NegatedFailureMessage(actual interface{}) (message string) { - return fmt.Sprintf("Jq expression `%s` applied to '%s' should not match: %s", matcher.JqExpr, matcher.InputString, matcher.ResMatcher.NegatedFailureMessage(actual)) -} +// func (matcher *matchJq) NegatedFailureMessage(actual interface{}) (message string) { +// return fmt.Sprintf("Jq expression `%s` applied to '%s' should not match: %s", matcher.JqExpr, matcher.InputString, matcher.ResMatcher.NegatedFailureMessage(actual)) +// } diff --git a/test/utils/kubectl.go b/test/utils/kubectl.go index c63bb7a5..fa817b82 100644 --- a/test/utils/kubectl.go +++ b/test/utils/kubectl.go @@ -1,6 +1,8 @@ //go:build test // +build test +// TODO: remove useless code + package utils import ( diff --git a/test/utils/shell-operator.go b/test/utils/shell-operator.go index 3cc2e977..3b9daa18 100644 --- a/test/utils/shell-operator.go +++ b/test/utils/shell-operator.go @@ -1,6 +1,8 @@ //go:build test // +build test +// TODO: remove useless code + package utils import ( diff --git a/test/utils/streamedexec.go b/test/utils/streamedexec.go index f610aa82..856086d4 100644 --- a/test/utils/streamedexec.go +++ b/test/utils/streamedexec.go @@ -1,6 +1,8 @@ //go:build test // +build test +// TODO: remove useless code + package utils import (