github.com/benoitkugler/goacve@v0.0.0-20201217100549-151ce6e55dc8/server/shared/views_test.go (about)

     1  package shared
     2  
     3  import (
     4  	"fmt"
     5  	"html/template"
     6  	"net/url"
     7  	"testing"
     8  )
     9  
    10  func TestFilename(t *testing.T) {
    11  	u := url.URL{Path: "Liste de vĂȘtements.pdf"}
    12  	encodedPath := u.String()
    13  	fmt.Println(encodedPath)
    14  }
    15  
    16  func TestPayload(t *testing.T) {
    17  	tem, err := template.ParseFiles("../static/bv/accueil.html")
    18  	if err != nil {
    19  		t.Fatal(err)
    20  	}
    21  	b, err := addPayload(tem, Camp{CampMeta: CampMeta{Label: "Test"}})
    22  	if err != nil {
    23  		t.Fatal(err)
    24  	}
    25  	fmt.Println(string(b))
    26  }
    27  
    28  func BenchmarkPayload(b *testing.B) {
    29  	file := "../static/bv/accueil.html"
    30  	for i := 0; i < b.N; i++ {
    31  		t, _ := template.ParseFiles(file)
    32  		t.Name()
    33  	}
    34  }