Simple blogging system written in Go https://goblog.app
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

34 lines
748 B

package main
import (
"net/http"
"testing"
"github.com/stretchr/testify/assert"
)
func Test_robotsTXT(t *testing.T) {
app := &goBlog{
cfg: &config{
Server: &configServer{
PublicAddress: "https://example.com",
},
},
}
h := http.HandlerFunc(app.serveRobotsTXT)
assert.HTTPStatusCode(t, h, http.MethodGet, "", nil, 200)
txt := assert.HTTPBody(h, http.MethodGet, "", nil)
assert.Equal(t, "User-agent: *\nSitemap: https://example.com/sitemap.xml", txt)
app.cfg.PrivateMode = &configPrivateMode{
Enabled: true,
}
h = http.HandlerFunc(app.serveRobotsTXT)
assert.HTTPStatusCode(t, h, http.MethodGet, "", nil, 200)
txt = assert.HTTPBody(h, http.MethodGet, "", nil)
assert.Equal(t, "User-agent: *\nDisallow: /", txt)
}