From 5967105ad2c70dabc2a5bf580de404fcd4d6c49f Mon Sep 17 00:00:00 2001 From: nachtmaar Date: Fri, 20 May 2022 15:35:47 +0200 Subject: [PATCH] Make test data more generic --- pkg/analyze/text_analyze_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/analyze/text_analyze_test.go b/pkg/analyze/text_analyze_test.go index 3de6a71b..07843e6e 100644 --- a/pkg/analyze/text_analyze_test.go +++ b/pkg/analyze/text_analyze_test.go @@ -489,13 +489,13 @@ func Test_textAnalyze(t *testing.T) { }, { Fail: &troubleshootv1beta2.SingleOutcome{ - Message: "There is a prefix not found error in {{ .SubName }} in namespace {{ .Namespace }}", + Message: "Error for CRD with name in {{ .CRDName }} in namespace {{ .Namespace }}", }, }, }, CollectorName: "text-collector-templated-regex-message", FileName: "cfile-1.txt", - RegexGroups: `"name":\s*"(?P.*?)".*namespace":\s*"(?P.*?)".*error":\s*.*"(?Pprefix not found.*?)"`, + RegexGroups: `"name":\s*"(?P.*?)".*namespace":\s*"(?P.*?)".*error":\s*.*"(?Pmyerror.*?)"`, }, expectResult: []AnalyzeResult{ { @@ -503,13 +503,13 @@ func Test_textAnalyze(t *testing.T) { IsWarn: false, IsFail: true, Title: "text-collector-templated-regex-message", - Message: "There is a prefix not found error in wrong-eventtypeprefix in namespace default", + Message: "Error for CRD with name in insert-crd-name-here in namespace default", IconKey: "kubernetes_text_analyze", IconURI: "https://troubleshoot.sh/images/analyzer-icons/text-analyze.svg?w=13&h=16", }, }, files: map[string][]byte{ - "text-collector-templated-regex-message/cfile-1.txt": []byte(`{"level":"ERROR","timestamp":"2022-05-17T20:37:41Z","caller":"controller/controller.go:317","message":"Reconciler error","context":{"name":"wrong-eventtypeprefix","namespace":"default","error":"prefix not found"}}`), + "text-collector-templated-regex-message/cfile-1.txt": []byte(`{"level":"ERROR","timestamp":"2022-05-17T20:37:41Z","caller":"controller/controller.go:317","message":"Reconciler error","context":{"name":"insert-crd-name-here","namespace":"default","error":"myerror"}}`), }, }, }