From 2400be06a123f8fce3088c41f13f26ee1d5aa0a0 Mon Sep 17 00:00:00 2001 From: Pranav Gaikwad Date: Sat, 11 Nov 2023 08:16:57 -0500 Subject: [PATCH] :bug: fix test Signed-off-by: Pranav Gaikwad --- demo-dep-output.yaml | 13 +++++++++++++ provider/lib_test.go | 18 +++++++++++++++--- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/demo-dep-output.yaml b/demo-dep-output.yaml index eb85f743..7ff450d3 100644 --- a/demo-dep-output.yaml +++ b/demo-dep-output.yaml @@ -344,6 +344,7 @@ - name: org.postgresql.postgresql version: 42.2.23 type: compile + resolvedIdentifier: 9cb217a3d5b640567ed7c6e8c11f389613c81c4d extras: artifactId: postgresql groupId: org.postgresql @@ -356,6 +357,7 @@ version: 3.5.0 type: runtime indirect: true + resolvedIdentifier: 2f50520c8abea66fbd8d26e481d3aef5c673b510 extras: artifactId: checker-qual groupId: org.checkerframework @@ -367,6 +369,7 @@ - name: com.oracle.database.jdbc.ojdbc8 version: 21.1.0.0 type: compile + resolvedIdentifier: 50044485aea10afd7defeee8109c5195b4d3cae2 extras: artifactId: ojdbc8 groupId: com.oracle.database.jdbc @@ -378,6 +381,7 @@ - name: ch.qos.logback.logback-classic version: 1.1.7 type: compile + resolvedIdentifier: 9865cf6994f9ff13fce0bf93f2054ef6c65bb462 extras: artifactId: logback-classic groupId: ch.qos.logback @@ -390,6 +394,7 @@ version: 1.1.7 type: compile indirect: true + resolvedIdentifier: 7873092d39ef741575ca91378a6a21c388363ac8 extras: artifactId: logback-core groupId: ch.qos.logback @@ -401,6 +406,7 @@ - name: org.hibernate.validator.hibernate-validator version: 6.2.0.Final type: compile + resolvedIdentifier: d6b0760dfffbf379cedd02f715ff4c9a2e215921 extras: artifactId: hibernate-validator groupId: org.hibernate.validator @@ -413,6 +419,7 @@ version: 2.0.2 type: compile indirect: true + resolvedIdentifier: 5eacc6522521f7eacb081f95cee1e231648461e7 extras: artifactId: jakarta.validation-api groupId: jakarta.validation @@ -425,6 +432,7 @@ version: 1.5.1 type: compile indirect: true + resolvedIdentifier: 3fe0bed568c62df5e89f4f174c101eab25345b6c extras: artifactId: classmate groupId: com.fasterxml @@ -462,6 +470,7 @@ version: 5.4.32.Final type: compile indirect: true + resolvedIdentifier: 99a5e10bf455337014c190e141ec631e9ff71663 extras: artifactId: hibernate-core groupId: org.hibernate @@ -539,6 +548,7 @@ version: 2.3.1 type: compile indirect: true + resolvedIdentifier: dd6dda9da676a54c5b36ca2806ff95ee017d8738 extras: artifactId: jaxb-runtime groupId: org.glassfish.jaxb @@ -590,6 +600,7 @@ version: 1.2.15 type: compile indirect: true + resolvedIdentifier: bb7b7ec0379982b97c62cd17465cb6d9155f68e8 extras: artifactId: FastInfoset groupId: com.sun.xml.fastinfoset @@ -641,6 +652,7 @@ version: 1.10.22 type: compile indirect: true + resolvedIdentifier: ef45d7e2cd1c600d279704f492ed5ce2ceb6cdb5 extras: artifactId: byte-buddy groupId: net.bytebuddy @@ -653,6 +665,7 @@ version: 1.1.1.Final type: compile indirect: true + resolvedIdentifier: a8485cab9484dda36e9a8c319e76b5cc18797b58 extras: artifactId: jboss-transaction-api_1.2_spec groupId: org.jboss.spec.javax.transaction diff --git a/provider/lib_test.go b/provider/lib_test.go index cc9fc886..82d753a2 100644 --- a/provider/lib_test.go +++ b/provider/lib_test.go @@ -11,6 +11,7 @@ func TestMultilineGrep(t *testing.T) { name string filePath string pattern string + window int want int wantErr bool }{ @@ -19,26 +20,37 @@ func TestMultilineGrep(t *testing.T) { filePath: "./testdata/small.xml", pattern: "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"", want: 2, + window: 1, wantErr: false, }, { name: "multi-line simple pattern", filePath: "./testdata/small.xml", pattern: "com.fasterxml.jackson.core.*?jackson-core.*", - want: 69, + want: 68, + window: 2, wantErr: false, }, { name: "multi-line complex pattern", filePath: "./testdata/small.xml", pattern: "(com.fasterxml.jackson.core|jackson-core).*?(jackson-core|com.fasterxml.jackson.core).*", - want: 69, + want: 68, + window: 2, + wantErr: false, + }, + { + name: "multi-line complex pattern", + filePath: "./testdata/big.xml", + pattern: "(io.konveyor.demo|config-utils).*?(config-utils|io.konveyor.demo).*", + want: 664, + window: 2, wantErr: false, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - got, err := MultilineGrep(context.TODO(), 5, tt.filePath, tt.pattern) + got, err := MultilineGrep(context.TODO(), tt.window, tt.filePath, tt.pattern) if (err != nil) != tt.wantErr { t.Errorf("MultilineGrep() error = %v, wantErr %v", err, tt.wantErr) return