Skip to content

Commit

Permalink
Ignoring address
Browse files Browse the repository at this point in the history
Signed-off-by: PrimalPimmy <[email protected]>
  • Loading branch information
PrimalPimmy committed Aug 23, 2023
1 parent e2cbe02 commit 945ab29
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions tests/k8tls-test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ package k8tlstest

import (
"encoding/csv"
"fmt"
"os"
"regexp"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
Expand Down Expand Up @@ -36,10 +34,12 @@ func matchCSV(file1 string, file2 string) {
}
}

// Compare headers
Expect(len(file1Records[0])).To(Equal(len(file2Records[0])))

for i := 0; i < len(file1Records[0]); i++ {
if i == addressColumnIndex {
continue
}
Expect(file1Records[0][i]).To(Equal(file2Records[0][i]))
}

Expand All @@ -48,14 +48,9 @@ func matchCSV(file1 string, file2 string) {
for i := 0; i < len(file1Records); i++ {
for j := 0; j < len(file1Records[i]); j++ {
if j == addressColumnIndex {
ipPortPattern := `^\d+\.\d+\.\d+\.\d+:\d+$`

// Check if both values match the IP:Port pattern
isMatch := regexp.MustCompile(ipPortPattern).MatchString(file1Records[i][j])
Expect(isMatch).To(BeTrue(), fmt.Sprintf("Address mismatch at row %d", i+1))
} else {
Expect(file1Records[i][j]).To(Equal(file2Records[i][j]))
continue
}
Expect(file1Records[i][j]).To(Equal(file2Records[i][j]))

}
}
Expand Down

0 comments on commit 945ab29

Please sign in to comment.