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

     1  package inscriptions
     2  
     3  import (
     4  	"encoding/json"
     5  	"fmt"
     6  	"html/template"
     7  	"os"
     8  	"testing"
     9  	"time"
    10  
    11  	"github.com/benoitkugler/goACVE/server/core/utils/mails"
    12  )
    13  
    14  func TestTemplate(t *testing.T) {
    15  	temp, err := template.New("test").Funcs(mails.FuncMap).Parse(`
    16  		<script>var x = {{ . }};</script>
    17  	`)
    18  	if err != nil {
    19  		t.Fatal(err)
    20  	}
    21  	if err = temp.Execute(os.Stdout, struct{ Test string }{"lmdklmsd"}); err != nil {
    22  		t.Fatal(err)
    23  	}
    24  }
    25  
    26  func TestDate(t *testing.T) {
    27  	date := time.Date(1998, 7, 8, 0, 0, 0, 0, time.UTC)
    28  	u, _ := json.Marshal(date)
    29  	fmt.Println(string(u))
    30  
    31  	s := `"1998-07-08T00:00:00Z"`
    32  	err := json.Unmarshal([]byte(s), &date)
    33  	if err != nil {
    34  		t.Fatal(err)
    35  	}
    36  	fmt.Println(date)
    37  }