/* * Hexacode Mailer * Package: gitlab.hexacode.org/go-libs/mailer * Maintainer: Azzis Arswendo * * Copyright (C) 2023 Hexacode Teknologi Indonesia * All Rights Reserved */ package mailer import ( "fmt" "testing" "gitlab.hexacode.org/go-libs/hctypes" ) func TestTemplate(t *testing.T) { _, err := NewTemplate("Hello {{ name }}") if err != nil { t.Fatal(err) } } func TestTemplateRender(t *testing.T) { tmpl, err := NewTemplate("Hello {{ name['first'] }} {{ name['last'] }}") if err != nil { t.Error(err) } data := hctypes.Dict{ "name": hctypes.Dict{ "first": "John", "last": "Doe", }, } render, err := tmpl.Render(data) if err != nil { t.Error(err) } if render != "Hello John Doe" { t.Error(fmt.Errorf("Expected 'Hello John Doe', got '%s'", render)) } }