Skip to content

Commit

Permalink
Fix windows tests (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
sercxanto authored Dec 22, 2023
1 parent 3bcce14 commit c13d019
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .changes/unreleased/Fixed-20231220-212936.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kind: Fixed
body: Fix Windows tests
time: 2023-12-20T21:29:36.737004753+01:00
2 changes: 1 addition & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, macos-latest] # "windows-latest" needs to be fixed, before enabling
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}

steps:
Expand Down
5 changes: 4 additions & 1 deletion internal/pkg/batchconvert/batchconvert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"path/filepath"
"reflect"
"sort"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -79,7 +80,9 @@ func areFilesEqual(file1, file2 string) (bool, error) {
return false, err
}

return string(content1) == string(content2), nil
// Trim possible all line endings to avoid differences on Windows
// and with git autocrlf settings
return strings.ReplaceAll(string(content1), "\r", "") == strings.ReplaceAll(string(content2), "\r", ""), nil
}

func extractFileNames(paths []string) []string {
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/settings/testfiles/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ batchconvert:
sets:
- name: "name1"
inputdir: "/my/path11"
outputdir: "/my/path12"
outputdir: "/my/path12"
fileglobpattern: "*.csv"
filemaxagedays: 5
format: "Barclaycard"
Expand Down
6 changes: 5 additions & 1 deletion pkg/parser/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package parser

import (
"os"
"strings"
)

func areFilesEqual(file1, file2 string) bool {
Expand All @@ -13,5 +14,8 @@ func areFilesEqual(file1, file2 string) bool {
if err != nil {
return false
}
return string(file1Data) == string(file2Data)

// Trim possible all line endings to avoid differences on Windows
// and with git autocrlf settings
return strings.ReplaceAll(string(file1Data), "\r", "") == strings.ReplaceAll(string(file2Data), "\r", "")
}

0 comments on commit c13d019

Please sign in to comment.