(t *testing.T)
| 432 | } |
| 433 | } |
| 434 | func TestBuildHTMLPages(t *testing.T) { |
| 435 | t.Run("use static content", func(t *testing.T) { |
| 436 | p := PageRender("thing") |
| 437 | staticResourceMap[p] = true |
| 438 | tmpDir := t.TempDir() |
| 439 | tempBdir := bundleDir |
| 440 | bundleDir = tmpDir |
| 441 | t.Cleanup(func() { |
| 442 | bundleDir = tempBdir |
| 443 | }) |
| 444 | dir := fmt.Sprintf("%s%c%s", http.Dir(tmpDir), os.PathSeparator, p) |
| 445 | ioutil.WriteFile(dir, []byte("<body> thing </body> <head> thint2 </head>"), 0666) |
| 446 | o := buildHTMLPages([]byte(""), p) |
| 447 | if len(o.Head) != 1 && len(o.Body) != 1 { |
| 448 | t.Errorf("body and head len do not match") |
| 449 | } |
| 450 | }) |
| 451 | t.Run("wrap content", func(t *testing.T) { |
| 452 | p := PageRender("wrapme") |
| 453 | wrapDocRender[p] = &DocumentRenderer{ |
| 454 | fn: func(ctx context.Context, s string, b []byte, hd *htmlDoc) (*htmlDoc, context.Context) { |
| 455 | hd.Body = append(hd.Body, "thing thing") |
| 456 | return hd, ctx |
| 457 | }, |
| 458 | version: "some_version", |
| 459 | } |
| 460 | t.Cleanup(func() { |
| 461 | wrapDocRender[p] = nil |
| 462 | }) |
| 463 | o := buildHTMLPages([]byte(""), p) |
| 464 | if len(o.Body) != 1 { |
| 465 | t.Errorf("did not apply wrap doc correctly") |
| 466 | } |
| 467 | }) |
| 468 | } |
| 469 | func TestParseStaticDocument(t *testing.T) { |
| 470 | t.Run("valid content", func(t *testing.T) { |
| 471 | tempDir := t.TempDir() |
nothing calls this directly
no test coverage detected