Skip to content

Commit

Permalink
add if-statement that replace CRLF on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
KevRiver authored and aybabtme committed Nov 6, 2024
1 parent 3e25b91 commit 98a2250
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"encoding/json"
"os"
"path/filepath"
"runtime"
"strings"
"testing"

"github.com/humanlogio/humanlog/internal/pkg/config"
Expand Down Expand Up @@ -38,6 +40,13 @@ func TestHarness(t *testing.T) {
if err != nil {
t.Fatalf("reading config: %v", err)
}

if runtime.GOOS == "windows" {
input = replaceCRLF(input, "\r\n", "\n")
want = replaceCRLF(want, "\r\n", "\n")
cfgjson = replaceCRLF(cfgjson, "\r\n", "\n")
}

var cfg config.Config
if err := json.Unmarshal(cfgjson, &cfg); err != nil {
t.Fatalf("unmarshaling config: %v", err)
Expand Down Expand Up @@ -109,6 +118,11 @@ type byteranges struct {
ranges []*byterange
}

func replaceCRLF(org []byte, oldCRLF string, newCRLF string) []byte {
replaced := strings.ReplaceAll(string(org), oldCRLF, newCRLF)
return []byte(replaced)
}

func newByteRanges() *byteranges {
return &byteranges{}
}
Expand Down

0 comments on commit 98a2250

Please sign in to comment.