Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests to work on Windows (irrespective of line endings) #57

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions dynamic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package multitemplate
import (
"html/template"
"os"
"strings"
"testing"

"github.com/gin-gonic/gin"
Expand Down Expand Up @@ -81,7 +82,7 @@ func TestAddFromFilesDynamic(t *testing.T) {

w := performRequest(router, "GET", "/")
assert.Equal(t, 200, w.Code)
assert.Equal(t, "<p>Test Multiple Template</p>\nHi, this is article template\n", w.Body.String())
assert.Equal(t, "<p>Test Multiple Template</p>\nHi, this is article template\n", strings.ReplaceAll(w.Body.String(), "\r", ""))
}

func TestAddFromGlobDynamic(t *testing.T) {
Expand All @@ -95,7 +96,7 @@ func TestAddFromGlobDynamic(t *testing.T) {

w := performRequest(router, "GET", "/")
assert.Equal(t, 200, w.Code)
assert.Equal(t, "<p>Test Multiple Template</p>\nHi, this is login template\n", w.Body.String())
assert.Equal(t, "<p>Test Multiple Template</p>\nHi, this is login template\n", strings.ReplaceAll(w.Body.String(), "\r", ""))
}

func TestAddFromFSDynamic(t *testing.T) {
Expand All @@ -109,7 +110,7 @@ func TestAddFromFSDynamic(t *testing.T) {

w := performRequest(router, "GET", "/")
assert.Equal(t, 200, w.Code)
assert.Equal(t, "<p>Test Multiple Template</p>\nHi, this is article template\n", w.Body.String())
assert.Equal(t, "<p>Test Multiple Template</p>\nHi, this is article template\n", strings.ReplaceAll(w.Body.String(), "\r", ""))
}

func TestAddFromStringDynamic(t *testing.T) {
Expand Down Expand Up @@ -151,7 +152,7 @@ func TestAddFromFilesFruncsDynamic(t *testing.T) {

w := performRequest(router, "GET", "/")
assert.Equal(t, 200, w.Code)
assert.Equal(t, "Welcome to index template\n", w.Body.String())
assert.Equal(t, "Welcome to index template\n", strings.ReplaceAll(w.Body.String(), "\r", ""))
}

func TestPanicInvalidTypeBuilder(t *testing.T) {
Expand Down
9 changes: 5 additions & 4 deletions multitemplate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"net/http"
"net/http/httptest"
"os"
"strings"
"testing"

"github.com/gin-gonic/gin"
Expand Down Expand Up @@ -84,7 +85,7 @@ func TestAddFromFiles(t *testing.T) {

w := performRequest(router, "GET", "/")
assert.Equal(t, 200, w.Code)
assert.Equal(t, "<p>Test Multiple Template</p>\nHi, this is article template\n", w.Body.String())
assert.Equal(t, "<p>Test Multiple Template</p>\nHi, this is article template\n", strings.ReplaceAll(w.Body.String(), "\r", ""))
}

func TestAddFromGlob(t *testing.T) {
Expand All @@ -98,7 +99,7 @@ func TestAddFromGlob(t *testing.T) {

w := performRequest(router, "GET", "/")
assert.Equal(t, 200, w.Code)
assert.Equal(t, "<p>Test Multiple Template</p>\nHi, this is login template\n", w.Body.String())
assert.Equal(t, "<p>Test Multiple Template</p>\nHi, this is login template\n", strings.ReplaceAll(w.Body.String(), "\r", ""))
}

func TestAddFromFS(t *testing.T) {
Expand All @@ -112,7 +113,7 @@ func TestAddFromFS(t *testing.T) {

w := performRequest(router, "GET", "/")
assert.Equal(t, 200, w.Code)
assert.Equal(t, "<p>Test Multiple Template</p>\nHi, this is article template\n", w.Body.String())
assert.Equal(t, "<p>Test Multiple Template</p>\nHi, this is article template\n", strings.ReplaceAll(w.Body.String(), "\r", ""))
}

func TestAddFromString(t *testing.T) {
Expand Down Expand Up @@ -154,7 +155,7 @@ func TestAddFromFilesFruncs(t *testing.T) {

w := performRequest(router, "GET", "/")
assert.Equal(t, 200, w.Code)
assert.Equal(t, "Welcome to index template\n", w.Body.String())
assert.Equal(t, "Welcome to index template\n", strings.ReplaceAll(w.Body.String(), "\r", ""))
}

func TestDuplicateTemplate(t *testing.T) {
Expand Down