Spaces:
Paused
Paused
ML Intern deploy
Deploy httpSMS gateway to Hugging Face Spaces (Docker SDK): nginx :7860 -> Go API :8000, Nuxt SPA, Android APK, bootstrap-mode entrypoint
83a59ca Download api/pkg/emails/hermes_theme_test.go from red-kit/httpsms-gateway: direct link, hf CLI and curl.
- Browser
- Download file 1.31 kB
-
https://huggingface.co/spaces/red-kit/httpsms-gateway/resolve/main/api/pkg/emails/hermes_theme_test.go
- Command line
-
hf download hf://spaces/red-kit/httpsms-gateway/api/pkg/emails/hermes_theme_test.go
-
curl -L -o hermes_theme_test.go https://huggingface.co/spaces/red-kit/httpsms-gateway/resolve/main/api/pkg/emails/hermes_theme_test.go
1.31 kB
| package emails | |
| import ( | |
| "html/template" | |
| "testing" | |
| "github.com/go-hermes/hermes/v2" | |
| "github.com/stretchr/testify/assert" | |
| "github.com/stretchr/testify/require" | |
| ) | |
| func TestHermesThemeRendersUnsafeDictionaryValueOnlyWhenProvided(t *testing.T) { | |
| generator := (&HermesGeneratorConfig{ | |
| AppURL: "https://httpsms.com", | |
| AppName: "httpSMS", | |
| AppLogoURL: "https://httpsms.com/logo.png", | |
| }).Generator() | |
| email := hermes.Email{ | |
| Body: hermes.Body{ | |
| Title: "Hello", | |
| Dictionary: []hermes.Entry{ | |
| {Key: "Normal", Value: "<b>escaped</b>"}, | |
| { | |
| Key: "Payload", | |
| Value: "plain payload", | |
| UnsafeValue: template.HTML(`<pre style="white-space:pre-wrap">rich payload</pre>`), | |
| }, | |
| }, | |
| }, | |
| } | |
| htmlEmail, err := generator.GenerateHTML(email) | |
| require.NoError(t, err) | |
| textEmail, err := generator.GeneratePlainText(email) | |
| require.NoError(t, err) | |
| assert.Contains(t, htmlEmail, `<b>escaped</b>`) | |
| assert.NotContains(t, htmlEmail, `<b>escaped</b>`) | |
| assert.Contains(t, htmlEmail, `<pre style="white-space:pre-wrap">rich payload</pre>`) | |
| assert.NotContains(t, htmlEmail, `<dd>plain payload</dd>`) | |
| assert.Contains(t, textEmail, "Normal: <b>escaped</b>") | |
| assert.Contains(t, textEmail, "Payload: plain payload") | |
| assert.NotContains(t, textEmail, "<pre") | |
| } | |