How to use Default method of html Package

Best K6 code snippet using html.Default

layout_test.go

Source:layout_test.go Github

copy

Full Screen

1// Copyright 2017-present The Hugo Authors. All rights reserved.2//3// Licensed under the Apache License, Version 2.0 (the "License");4// you may not use this file except in compliance with the License.5// You may obtain a copy of the License at6// http://www.apache.org/licenses/LICENSE-2.07//8// Unless required by applicable law or agreed to in writing, software9// distributed under the License is distributed on an "AS IS" BASIS,10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.11// See the License for the specific language governing permissions and12// limitations under the License.13package output14import (15 "fmt"16 "reflect"17 "strings"18 "testing"19 "github.com/gohugoio/hugo/media"20 qt "github.com/frankban/quicktest"21 "github.com/kylelemons/godebug/diff"22)23func TestLayout(t *testing.T) {24 c := qt.New(t)25 noExtNoDelimMediaType := media.WithDelimiterAndSuffixes(media.TextType, "", "")26 noExtMediaType := media.WithDelimiterAndSuffixes(media.TextType, ".", "")27 var (28 ampType = Format{29 Name: "AMP",30 MediaType: media.HTMLType,31 BaseName: "index",32 }33 htmlFormat = HTMLFormat34 noExtDelimFormat = Format{35 Name: "NEM",36 MediaType: noExtNoDelimMediaType,37 BaseName: "_redirects",38 }39 noExt = Format{40 Name: "NEX",41 MediaType: noExtMediaType,42 BaseName: "next",43 }44 )45 for _, this := range []struct {46 name string47 layoutDescriptor LayoutDescriptor48 layoutOverride string49 format Format50 expect []string51 }{52 {53 "Home",54 LayoutDescriptor{Kind: "home"},55 "", ampType,56 []string{57 "index.amp.html",58 "home.amp.html",59 "list.amp.html",60 "index.html",61 "home.html",62 "list.html",63 "_default/index.amp.html",64 "_default/home.amp.html",65 "_default/list.amp.html",66 "_default/index.html",67 "_default/home.html",68 "_default/list.html",69 },70 },71 {72 "Home baseof",73 LayoutDescriptor{Kind: "home", Baseof: true},74 "", ampType,75 []string{76 "index-baseof.amp.html",77 "home-baseof.amp.html",78 "list-baseof.amp.html",79 "baseof.amp.html",80 "index-baseof.html",81 "home-baseof.html",82 "list-baseof.html",83 "baseof.html",84 "_default/index-baseof.amp.html",85 "_default/home-baseof.amp.html",86 "_default/list-baseof.amp.html",87 "_default/baseof.amp.html",88 "_default/index-baseof.html",89 "_default/home-baseof.html",90 "_default/list-baseof.html",91 "_default/baseof.html",92 },93 },94 {95 "Home, HTML",96 LayoutDescriptor{Kind: "home"},97 "", htmlFormat,98 // We will eventually get to index.html. This looks stuttery, but makes the lookup logic easy to understand.99 []string{100 "index.html.html",101 "home.html.html",102 "list.html.html",103 "index.html",104 "home.html",105 "list.html",106 "_default/index.html.html",107 "_default/home.html.html",108 "_default/list.html.html",109 "_default/index.html",110 "_default/home.html",111 "_default/list.html",112 },113 },114 {115 "Home, HTML, baseof",116 LayoutDescriptor{Kind: "home", Baseof: true},117 "", htmlFormat,118 []string{119 "index-baseof.html.html",120 "home-baseof.html.html",121 "list-baseof.html.html",122 "baseof.html.html",123 "index-baseof.html",124 "home-baseof.html",125 "list-baseof.html",126 "baseof.html",127 "_default/index-baseof.html.html",128 "_default/home-baseof.html.html",129 "_default/list-baseof.html.html",130 "_default/baseof.html.html",131 "_default/index-baseof.html",132 "_default/home-baseof.html",133 "_default/list-baseof.html",134 "_default/baseof.html",135 },136 },137 {138 "Home, french language",139 LayoutDescriptor{Kind: "home", Lang: "fr"},140 "", ampType,141 []string{142 "index.fr.amp.html",143 "home.fr.amp.html",144 "list.fr.amp.html",145 "index.amp.html",146 "home.amp.html",147 "list.amp.html",148 "index.fr.html",149 "home.fr.html",150 "list.fr.html",151 "index.html",152 "home.html",153 "list.html",154 "_default/index.fr.amp.html",155 "_default/home.fr.amp.html",156 "_default/list.fr.amp.html",157 "_default/index.amp.html",158 "_default/home.amp.html",159 "_default/list.amp.html",160 "_default/index.fr.html",161 "_default/home.fr.html",162 "_default/list.fr.html",163 "_default/index.html",164 "_default/home.html",165 "_default/list.html",166 },167 },168 {169 "Home, no ext or delim",170 LayoutDescriptor{Kind: "home"},171 "", noExtDelimFormat,172 []string{173 "index.nem",174 "home.nem",175 "list.nem",176 "_default/index.nem",177 "_default/home.nem",178 "_default/list.nem",179 },180 },181 {182 "Home, no ext",183 LayoutDescriptor{Kind: "home"},184 "", noExt,185 []string{186 "index.nex",187 "home.nex",188 "list.nex",189 "_default/index.nex",190 "_default/home.nex",191 "_default/list.nex",192 },193 },194 {195 "Page, no ext or delim",196 LayoutDescriptor{Kind: "page"},197 "", noExtDelimFormat,198 []string{"_default/single.nem"},199 },200 {201 "Section",202 LayoutDescriptor{Kind: "section", Section: "sect1"},203 "", ampType,204 []string{205 "sect1/sect1.amp.html",206 "sect1/section.amp.html",207 "sect1/list.amp.html",208 "sect1/sect1.html",209 "sect1/section.html",210 "sect1/list.html",211 "section/sect1.amp.html",212 "section/section.amp.html",213 "section/list.amp.html",214 "section/sect1.html",215 "section/section.html",216 "section/list.html",217 "_default/sect1.amp.html",218 "_default/section.amp.html",219 "_default/list.amp.html",220 "_default/sect1.html",221 "_default/section.html",222 "_default/list.html",223 },224 },225 {226 "Section, baseof",227 LayoutDescriptor{Kind: "section", Section: "sect1", Baseof: true},228 "", ampType,229 []string{230 "sect1/sect1-baseof.amp.html",231 "sect1/section-baseof.amp.html",232 "sect1/list-baseof.amp.html",233 "sect1/baseof.amp.html",234 "sect1/sect1-baseof.html",235 "sect1/section-baseof.html",236 "sect1/list-baseof.html",237 "sect1/baseof.html",238 "section/sect1-baseof.amp.html",239 "section/section-baseof.amp.html",240 "section/list-baseof.amp.html",241 "section/baseof.amp.html",242 "section/sect1-baseof.html",243 "section/section-baseof.html",244 "section/list-baseof.html",245 "section/baseof.html",246 "_default/sect1-baseof.amp.html",247 "_default/section-baseof.amp.html",248 "_default/list-baseof.amp.html",249 "_default/baseof.amp.html",250 "_default/sect1-baseof.html",251 "_default/section-baseof.html",252 "_default/list-baseof.html",253 "_default/baseof.html",254 },255 },256 {257 "Section, baseof, French, AMP",258 LayoutDescriptor{Kind: "section", Section: "sect1", Lang: "fr", Baseof: true},259 "", ampType,260 []string{261 "sect1/sect1-baseof.fr.amp.html",262 "sect1/section-baseof.fr.amp.html",263 "sect1/list-baseof.fr.amp.html",264 "sect1/baseof.fr.amp.html",265 "sect1/sect1-baseof.amp.html",266 "sect1/section-baseof.amp.html",267 "sect1/list-baseof.amp.html",268 "sect1/baseof.amp.html",269 "sect1/sect1-baseof.fr.html",270 "sect1/section-baseof.fr.html",271 "sect1/list-baseof.fr.html",272 "sect1/baseof.fr.html",273 "sect1/sect1-baseof.html",274 "sect1/section-baseof.html",275 "sect1/list-baseof.html",276 "sect1/baseof.html",277 "section/sect1-baseof.fr.amp.html",278 "section/section-baseof.fr.amp.html",279 "section/list-baseof.fr.amp.html",280 "section/baseof.fr.amp.html",281 "section/sect1-baseof.amp.html",282 "section/section-baseof.amp.html",283 "section/list-baseof.amp.html",284 "section/baseof.amp.html",285 "section/sect1-baseof.fr.html",286 "section/section-baseof.fr.html",287 "section/list-baseof.fr.html",288 "section/baseof.fr.html",289 "section/sect1-baseof.html",290 "section/section-baseof.html",291 "section/list-baseof.html",292 "section/baseof.html",293 "_default/sect1-baseof.fr.amp.html",294 "_default/section-baseof.fr.amp.html",295 "_default/list-baseof.fr.amp.html",296 "_default/baseof.fr.amp.html",297 "_default/sect1-baseof.amp.html",298 "_default/section-baseof.amp.html",299 "_default/list-baseof.amp.html",300 "_default/baseof.amp.html",301 "_default/sect1-baseof.fr.html",302 "_default/section-baseof.fr.html",303 "_default/list-baseof.fr.html",304 "_default/baseof.fr.html",305 "_default/sect1-baseof.html",306 "_default/section-baseof.html",307 "_default/list-baseof.html",308 "_default/baseof.html",309 },310 },311 {312 "Section with layout",313 LayoutDescriptor{Kind: "section", Section: "sect1", Layout: "mylayout"},314 "", ampType,315 []string{316 "sect1/mylayout.amp.html",317 "sect1/sect1.amp.html",318 "sect1/section.amp.html",319 "sect1/list.amp.html",320 "sect1/mylayout.html",321 "sect1/sect1.html",322 "sect1/section.html",323 "sect1/list.html",324 "section/mylayout.amp.html",325 "section/sect1.amp.html",326 "section/section.amp.html",327 "section/list.amp.html",328 "section/mylayout.html",329 "section/sect1.html",330 "section/section.html",331 "section/list.html",332 "_default/mylayout.amp.html",333 "_default/sect1.amp.html",334 "_default/section.amp.html",335 "_default/list.amp.html",336 "_default/mylayout.html",337 "_default/sect1.html",338 "_default/section.html",339 "_default/list.html",340 },341 },342 {343 "Term, French, AMP",344 LayoutDescriptor{Kind: "term", Section: "tags", Lang: "fr"},345 "", ampType,346 []string{347 "term/term.fr.amp.html",348 "term/tags.fr.amp.html",349 "term/taxonomy.fr.amp.html",350 "term/list.fr.amp.html",351 "term/term.amp.html",352 "term/tags.amp.html",353 "term/taxonomy.amp.html",354 "term/list.amp.html",355 "term/term.fr.html",356 "term/tags.fr.html",357 "term/taxonomy.fr.html",358 "term/list.fr.html",359 "term/term.html",360 "term/tags.html",361 "term/taxonomy.html",362 "term/list.html",363 "taxonomy/term.fr.amp.html",364 "taxonomy/tags.fr.amp.html",365 "taxonomy/taxonomy.fr.amp.html",366 "taxonomy/list.fr.amp.html",367 "taxonomy/term.amp.html",368 "taxonomy/tags.amp.html",369 "taxonomy/taxonomy.amp.html",370 "taxonomy/list.amp.html",371 "taxonomy/term.fr.html",372 "taxonomy/tags.fr.html",373 "taxonomy/taxonomy.fr.html",374 "taxonomy/list.fr.html",375 "taxonomy/term.html",376 "taxonomy/tags.html",377 "taxonomy/taxonomy.html",378 "taxonomy/list.html",379 "tags/term.fr.amp.html",380 "tags/tags.fr.amp.html",381 "tags/taxonomy.fr.amp.html",382 "tags/list.fr.amp.html",383 "tags/term.amp.html",384 "tags/tags.amp.html",385 "tags/taxonomy.amp.html",386 "tags/list.amp.html",387 "tags/term.fr.html",388 "tags/tags.fr.html",389 "tags/taxonomy.fr.html",390 "tags/list.fr.html",391 "tags/term.html",392 "tags/tags.html",393 "tags/taxonomy.html",394 "tags/list.html",395 "_default/term.fr.amp.html",396 "_default/tags.fr.amp.html",397 "_default/taxonomy.fr.amp.html",398 "_default/list.fr.amp.html",399 "_default/term.amp.html",400 "_default/tags.amp.html",401 "_default/taxonomy.amp.html",402 "_default/list.amp.html",403 "_default/term.fr.html",404 "_default/tags.fr.html",405 "_default/taxonomy.fr.html",406 "_default/list.fr.html",407 "_default/term.html",408 "_default/tags.html",409 "_default/taxonomy.html",410 "_default/list.html",411 },412 },413 {414 "Term, baseof, French, AMP",415 LayoutDescriptor{Kind: "term", Section: "tags", Lang: "fr", Baseof: true},416 "", ampType,417 []string{418 "term/term-baseof.fr.amp.html",419 "term/tags-baseof.fr.amp.html",420 "term/taxonomy-baseof.fr.amp.html",421 "term/list-baseof.fr.amp.html",422 "term/baseof.fr.amp.html",423 "term/term-baseof.amp.html",424 "term/tags-baseof.amp.html",425 "term/taxonomy-baseof.amp.html",426 "term/list-baseof.amp.html",427 "term/baseof.amp.html",428 "term/term-baseof.fr.html",429 "term/tags-baseof.fr.html",430 "term/taxonomy-baseof.fr.html",431 "term/list-baseof.fr.html",432 "term/baseof.fr.html",433 "term/term-baseof.html",434 "term/tags-baseof.html",435 "term/taxonomy-baseof.html",436 "term/list-baseof.html",437 "term/baseof.html",438 "taxonomy/term-baseof.fr.amp.html",439 "taxonomy/tags-baseof.fr.amp.html",440 "taxonomy/taxonomy-baseof.fr.amp.html",441 "taxonomy/list-baseof.fr.amp.html",442 "taxonomy/baseof.fr.amp.html",443 "taxonomy/term-baseof.amp.html",444 "taxonomy/tags-baseof.amp.html",445 "taxonomy/taxonomy-baseof.amp.html",446 "taxonomy/list-baseof.amp.html",447 "taxonomy/baseof.amp.html",448 "taxonomy/term-baseof.fr.html",449 "taxonomy/tags-baseof.fr.html",450 "taxonomy/taxonomy-baseof.fr.html",451 "taxonomy/list-baseof.fr.html",452 "taxonomy/baseof.fr.html",453 "taxonomy/term-baseof.html",454 "taxonomy/tags-baseof.html",455 "taxonomy/taxonomy-baseof.html",456 "taxonomy/list-baseof.html",457 "taxonomy/baseof.html",458 "tags/term-baseof.fr.amp.html",459 "tags/tags-baseof.fr.amp.html",460 "tags/taxonomy-baseof.fr.amp.html",461 "tags/list-baseof.fr.amp.html",462 "tags/baseof.fr.amp.html",463 "tags/term-baseof.amp.html",464 "tags/tags-baseof.amp.html",465 "tags/taxonomy-baseof.amp.html",466 "tags/list-baseof.amp.html",467 "tags/baseof.amp.html",468 "tags/term-baseof.fr.html",469 "tags/tags-baseof.fr.html",470 "tags/taxonomy-baseof.fr.html",471 "tags/list-baseof.fr.html",472 "tags/baseof.fr.html",473 "tags/term-baseof.html",474 "tags/tags-baseof.html",475 "tags/taxonomy-baseof.html",476 "tags/list-baseof.html",477 "tags/baseof.html",478 "_default/term-baseof.fr.amp.html",479 "_default/tags-baseof.fr.amp.html",480 "_default/taxonomy-baseof.fr.amp.html",481 "_default/list-baseof.fr.amp.html",482 "_default/baseof.fr.amp.html",483 "_default/term-baseof.amp.html",484 "_default/tags-baseof.amp.html",485 "_default/taxonomy-baseof.amp.html",486 "_default/list-baseof.amp.html",487 "_default/baseof.amp.html",488 "_default/term-baseof.fr.html",489 "_default/tags-baseof.fr.html",490 "_default/taxonomy-baseof.fr.html",491 "_default/list-baseof.fr.html",492 "_default/baseof.fr.html",493 "_default/term-baseof.html",494 "_default/tags-baseof.html",495 "_default/taxonomy-baseof.html",496 "_default/list-baseof.html",497 "_default/baseof.html",498 },499 },500 {501 "Term",502 LayoutDescriptor{Kind: "term", Section: "tags"},503 "", ampType,504 []string{505 "term/term.amp.html",506 "term/tags.amp.html",507 "term/taxonomy.amp.html",508 "term/list.amp.html",509 "term/term.html",510 "term/tags.html",511 "term/taxonomy.html",512 "term/list.html",513 "taxonomy/term.amp.html",514 "taxonomy/tags.amp.html",515 "taxonomy/taxonomy.amp.html",516 "taxonomy/list.amp.html",517 "taxonomy/term.html",518 "taxonomy/tags.html",519 "taxonomy/taxonomy.html",520 "taxonomy/list.html",521 "tags/term.amp.html",522 "tags/tags.amp.html",523 "tags/taxonomy.amp.html",524 "tags/list.amp.html",525 "tags/term.html",526 "tags/tags.html",527 "tags/taxonomy.html",528 "tags/list.html",529 "_default/term.amp.html",530 "_default/tags.amp.html",531 "_default/taxonomy.amp.html",532 "_default/list.amp.html",533 "_default/term.html",534 "_default/tags.html",535 "_default/taxonomy.html",536 "_default/list.html",537 },538 },539 {540 "Taxonomy",541 LayoutDescriptor{Kind: "taxonomy", Section: "categories"},542 "", ampType,543 []string{544 "categories/categories.terms.amp.html",545 "categories/terms.amp.html",546 "categories/taxonomy.amp.html",547 "categories/list.amp.html",548 "categories/categories.terms.html",549 "categories/terms.html",550 "categories/taxonomy.html",551 "categories/list.html",552 "taxonomy/categories.terms.amp.html",553 "taxonomy/terms.amp.html",554 "taxonomy/taxonomy.amp.html",555 "taxonomy/list.amp.html",556 "taxonomy/categories.terms.html",557 "taxonomy/terms.html",558 "taxonomy/taxonomy.html",559 "taxonomy/list.html",560 "_default/categories.terms.amp.html",561 "_default/terms.amp.html",562 "_default/taxonomy.amp.html",563 "_default/list.amp.html",564 "_default/categories.terms.html",565 "_default/terms.html",566 "_default/taxonomy.html",567 "_default/list.html",568 },569 },570 {571 "Page",572 LayoutDescriptor{Kind: "page"},573 "", ampType,574 []string{575 "_default/single.amp.html",576 "_default/single.html",577 },578 },579 {580 "Page, baseof",581 LayoutDescriptor{Kind: "page", Baseof: true},582 "", ampType,583 []string{584 "_default/single-baseof.amp.html",585 "_default/baseof.amp.html",586 "_default/single-baseof.html",587 "_default/baseof.html",588 },589 },590 {591 "Page with layout",592 LayoutDescriptor{Kind: "page", Layout: "mylayout"},593 "", ampType,594 []string{595 "_default/mylayout.amp.html",596 "_default/single.amp.html",597 "_default/mylayout.html",598 "_default/single.html",599 },600 },601 {602 "Page with layout, baseof",603 LayoutDescriptor{Kind: "page", Layout: "mylayout", Baseof: true},604 "", ampType,605 []string{606 "_default/mylayout-baseof.amp.html",607 "_default/single-baseof.amp.html",608 "_default/baseof.amp.html",609 "_default/mylayout-baseof.html",610 "_default/single-baseof.html",611 "_default/baseof.html",612 },613 },614 {615 "Page with layout and type",616 LayoutDescriptor{Kind: "page", Layout: "mylayout", Type: "myttype"},617 "", ampType,618 []string{619 "myttype/mylayout.amp.html",620 "myttype/single.amp.html",621 "myttype/mylayout.html",622 "myttype/single.html",623 "_default/mylayout.amp.html",624 "_default/single.amp.html",625 "_default/mylayout.html",626 "_default/single.html",627 },628 },629 {630 "Page baseof with layout and type",631 LayoutDescriptor{Kind: "page", Layout: "mylayout", Type: "myttype", Baseof: true},632 "", ampType,633 []string{634 "myttype/mylayout-baseof.amp.html",635 "myttype/single-baseof.amp.html",636 "myttype/baseof.amp.html",637 "myttype/mylayout-baseof.html",638 "myttype/single-baseof.html",639 "myttype/baseof.html",640 "_default/mylayout-baseof.amp.html",641 "_default/single-baseof.amp.html",642 "_default/baseof.amp.html",643 "_default/mylayout-baseof.html",644 "_default/single-baseof.html",645 "_default/baseof.html",646 },647 },648 {649 "Page baseof with layout and type in French",650 LayoutDescriptor{Kind: "page", Layout: "mylayout", Type: "myttype", Lang: "fr", Baseof: true},651 "", ampType,652 []string{653 "myttype/mylayout-baseof.fr.amp.html",654 "myttype/single-baseof.fr.amp.html",655 "myttype/baseof.fr.amp.html",656 "myttype/mylayout-baseof.amp.html",657 "myttype/single-baseof.amp.html",658 "myttype/baseof.amp.html",659 "myttype/mylayout-baseof.fr.html",660 "myttype/single-baseof.fr.html",661 "myttype/baseof.fr.html",662 "myttype/mylayout-baseof.html",663 "myttype/single-baseof.html",664 "myttype/baseof.html",665 "_default/mylayout-baseof.fr.amp.html",666 "_default/single-baseof.fr.amp.html",667 "_default/baseof.fr.amp.html",668 "_default/mylayout-baseof.amp.html",669 "_default/single-baseof.amp.html",670 "_default/baseof.amp.html",671 "_default/mylayout-baseof.fr.html",672 "_default/single-baseof.fr.html",673 "_default/baseof.fr.html",674 "_default/mylayout-baseof.html",675 "_default/single-baseof.html",676 "_default/baseof.html",677 },678 },679 {680 "Page with layout and type with subtype",681 LayoutDescriptor{Kind: "page", Layout: "mylayout", Type: "myttype/mysubtype"},682 "", ampType,683 []string{684 "myttype/mysubtype/mylayout.amp.html",685 "myttype/mysubtype/single.amp.html",686 "myttype/mysubtype/mylayout.html",687 "myttype/mysubtype/single.html",688 "_default/mylayout.amp.html",689 "_default/single.amp.html",690 "_default/mylayout.html",691 "_default/single.html",692 },693 },694 // RSS695 {696 "RSS Home",697 LayoutDescriptor{Kind: "home"},698 "", RSSFormat,699 []string{700 "index.rss.xml",701 "home.rss.xml",702 "rss.xml",703 "list.rss.xml",704 "index.xml",705 "home.xml",706 "list.xml",707 "_default/index.rss.xml",708 "_default/home.rss.xml",709 "_default/rss.xml",710 "_default/list.rss.xml",711 "_default/index.xml",712 "_default/home.xml",713 "_default/list.xml",714 "_internal/_default/rss.xml",715 },716 },717 {718 "RSS Home, baseof",719 LayoutDescriptor{Kind: "home", Baseof: true},720 "", RSSFormat,721 []string{722 "index-baseof.rss.xml",723 "home-baseof.rss.xml",724 "list-baseof.rss.xml",725 "baseof.rss.xml",726 "index-baseof.xml",727 "home-baseof.xml",728 "list-baseof.xml",729 "baseof.xml",730 "_default/index-baseof.rss.xml",731 "_default/home-baseof.rss.xml",732 "_default/list-baseof.rss.xml",733 "_default/baseof.rss.xml",734 "_default/index-baseof.xml",735 "_default/home-baseof.xml",736 "_default/list-baseof.xml",737 "_default/baseof.xml",738 },739 },740 {741 "RSS Section",742 LayoutDescriptor{Kind: "section", Section: "sect1"},743 "", RSSFormat,744 []string{745 "sect1/sect1.rss.xml",746 "sect1/section.rss.xml",747 "sect1/rss.xml",748 "sect1/list.rss.xml",749 "sect1/sect1.xml",750 "sect1/section.xml",751 "sect1/list.xml",752 "section/sect1.rss.xml",753 "section/section.rss.xml",754 "section/rss.xml",755 "section/list.rss.xml",756 "section/sect1.xml",757 "section/section.xml",758 "section/list.xml",759 "_default/sect1.rss.xml",760 "_default/section.rss.xml",761 "_default/rss.xml",762 "_default/list.rss.xml",763 "_default/sect1.xml",764 "_default/section.xml",765 "_default/list.xml",766 "_internal/_default/rss.xml",767 },768 },769 {770 "RSS Term",771 LayoutDescriptor{Kind: "term", Section: "tag"},772 "", RSSFormat,773 []string{774 "term/term.rss.xml",775 "term/tag.rss.xml",776 "term/taxonomy.rss.xml",777 "term/rss.xml",778 "term/list.rss.xml",779 "term/term.xml",780 "term/tag.xml",781 "term/taxonomy.xml",782 "term/list.xml",783 "taxonomy/term.rss.xml",784 "taxonomy/tag.rss.xml",785 "taxonomy/taxonomy.rss.xml",786 "taxonomy/rss.xml",787 "taxonomy/list.rss.xml",788 "taxonomy/term.xml",789 "taxonomy/tag.xml",790 "taxonomy/taxonomy.xml",791 "taxonomy/list.xml",792 "tag/term.rss.xml",793 "tag/tag.rss.xml",794 "tag/taxonomy.rss.xml",795 "tag/rss.xml",796 "tag/list.rss.xml",797 "tag/term.xml",798 "tag/tag.xml",799 "tag/taxonomy.xml",800 "tag/list.xml",801 "_default/term.rss.xml",802 "_default/tag.rss.xml",803 "_default/taxonomy.rss.xml",804 "_default/rss.xml",805 "_default/list.rss.xml",806 "_default/term.xml",807 "_default/tag.xml",808 "_default/taxonomy.xml",809 "_default/list.xml",810 "_internal/_default/rss.xml",811 },812 },813 {814 "RSS Taxonomy",815 LayoutDescriptor{Kind: "taxonomy", Section: "tag"},816 "", RSSFormat,817 []string{818 "tag/tag.terms.rss.xml",819 "tag/terms.rss.xml",820 "tag/taxonomy.rss.xml",821 "tag/rss.xml",822 "tag/list.rss.xml",823 "tag/tag.terms.xml",824 "tag/terms.xml",825 "tag/taxonomy.xml",826 "tag/list.xml",827 "taxonomy/tag.terms.rss.xml",828 "taxonomy/terms.rss.xml",829 "taxonomy/taxonomy.rss.xml",830 "taxonomy/rss.xml",831 "taxonomy/list.rss.xml",832 "taxonomy/tag.terms.xml",833 "taxonomy/terms.xml",834 "taxonomy/taxonomy.xml",835 "taxonomy/list.xml",836 "_default/tag.terms.rss.xml",837 "_default/terms.rss.xml",838 "_default/taxonomy.rss.xml",839 "_default/rss.xml",840 "_default/list.rss.xml",841 "_default/tag.terms.xml",842 "_default/terms.xml",843 "_default/taxonomy.xml",844 "_default/list.xml",845 "_internal/_default/rss.xml",846 },847 },848 {849 "Home plain text",850 LayoutDescriptor{Kind: "home"},851 "", JSONFormat,852 []string{853 "index.json.json",854 "home.json.json",855 "list.json.json",856 "index.json",857 "home.json",858 "list.json",859 "_default/index.json.json",860 "_default/home.json.json",861 "_default/list.json.json",862 "_default/index.json",863 "_default/home.json",864 "_default/list.json",865 },866 },867 {868 "Page plain text",869 LayoutDescriptor{Kind: "page"},870 "", JSONFormat,871 []string{872 "_default/single.json.json",873 "_default/single.json",874 },875 },876 {877 "Reserved section, shortcodes",878 LayoutDescriptor{Kind: "section", Section: "shortcodes", Type: "shortcodes"},879 "", ampType,880 []string{881 "section/shortcodes.amp.html",882 "section/section.amp.html",883 "section/list.amp.html",884 "section/shortcodes.html",885 "section/section.html",886 "section/list.html",887 "_default/shortcodes.amp.html",888 "_default/section.amp.html",889 "_default/list.amp.html",890 "_default/shortcodes.html",891 "_default/section.html",892 "_default/list.html",893 },894 },895 {896 "Reserved section, partials",897 LayoutDescriptor{Kind: "section", Section: "partials", Type: "partials"},898 "", ampType,899 []string{900 "section/partials.amp.html",901 "section/section.amp.html",902 "section/list.amp.html",903 "section/partials.html",904 "section/section.html",905 "section/list.html",906 "_default/partials.amp.html",907 "_default/section.amp.html",908 "_default/list.amp.html",909 "_default/partials.html",910 "_default/section.html",911 "_default/list.html",912 },913 },914 // This is currently always HTML only915 {916 "404, HTML",917 LayoutDescriptor{Kind: "404"},918 "", htmlFormat,919 []string{920 "404.html.html",921 "404.html",922 },923 },924 {925 "404, HTML baseof",926 LayoutDescriptor{Kind: "404", Baseof: true},927 "", htmlFormat,928 []string{929 "404-baseof.html.html",930 "baseof.html.html",931 "404-baseof.html",932 "baseof.html",933 "_default/404-baseof.html.html",934 "_default/baseof.html.html",935 "_default/404-baseof.html",936 "_default/baseof.html",937 },938 },939 {940 "Content hook",941 LayoutDescriptor{Kind: "render-link", RenderingHook: true, Layout: "mylayout", Section: "blog"},942 "", ampType,943 []string{944 "blog/_markup/render-link.amp.html",945 "blog/_markup/render-link.html",946 "_default/_markup/render-link.amp.html",947 "_default/_markup/render-link.html",948 },949 },950 } {951 c.Run(this.name, func(c *qt.C) {952 l := NewLayoutHandler()953 layouts, err := l.For(this.layoutDescriptor, this.format)954 c.Assert(err, qt.IsNil)955 c.Assert(layouts, qt.Not(qt.IsNil), qt.Commentf(this.layoutDescriptor.Kind))956 if !reflect.DeepEqual(layouts, this.expect) {957 r := strings.NewReplacer(958 "[", "\t\"",959 "]", "\",",960 " ", "\",\n\t\"",961 )962 fmtGot := r.Replace(fmt.Sprintf("%v", layouts))963 fmtExp := r.Replace(fmt.Sprintf("%v", this.expect))964 c.Fatalf("got %d items, expected %d:\nGot:\n\t%v\nExpected:\n\t%v\nDiff:\n%s", len(layouts), len(this.expect), layouts, this.expect, diff.Diff(fmtExp, fmtGot))965 }966 })967 }968}969func BenchmarkLayout(b *testing.B) {970 descriptor := LayoutDescriptor{Kind: "taxonomy", Section: "categories"}971 l := NewLayoutHandler()972 for i := 0; i < b.N; i++ {973 _, err := l.For(descriptor, HTMLFormat)974 if err != nil {975 panic(err)976 }977 }978}979func BenchmarkLayoutUncached(b *testing.B) {980 for i := 0; i < b.N; i++ {981 descriptor := LayoutDescriptor{Kind: "taxonomy", Section: "categories"}982 l := NewLayoutHandler()983 _, err := l.For(descriptor, HTMLFormat)984 if err != nil {985 panic(err)986 }987 }988}...

Full Screen

Full Screen

init_test.go

Source:init_test.go Github

copy

Full Screen

1package crawler2import (3 "bytes"4 "context"5 "io/ioutil"6 "net/http"7 "net/http/httptest"8 "net/url"9 "os"10 "testing"11)12var defaultCrawler *Crawler13var defaultResp *http.Response14var defaultSite Site15var parentURL *url.URL16var homepage *url.URL17var about *url.URL18var emptyPage *httptest.Server19var emptyPageURL *url.URL20// {21// 0:22// 1:23// 1,24// 2,25// }26var mock0 *httptest.Server27var mock0URL *url.URL28var mock01 *httptest.Server29var mock01URL *url.URL30var mock011 *httptest.Server31var mock011URL *url.URL32var mock012 *httptest.Server33var mock012URL *url.URL34func TestMain(m *testing.M) {35 os.Exit(testMain(m))36}37func testMain(m *testing.M) int {38 defaultCrawler = NewCrawler(context.Background(), CrawlerOpt{})39 defaultResp = &http.Response{40 Header: http.Header{41 "Content-Type": {"text/html"},42 },43 Body: ioutil.NopCloser(bytes.NewBuffer([]byte(`44 <html><body>45 <a href="/1">1</a>46 </body></html>`))),47 }48 defaultSite = Site{}49 parentURL, _ = url.Parse("https://monzo.com")50 homepage, _ = url.Parse("https://monzo.com/")51 about, _ = url.Parse("https://monzo.com/about")52 emptyPage = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {53 w.Header().Set("Content-Type", "text/html")54 w.Write([]byte(`<html><body></body></html>`))55 }))56 defer emptyPage.Close()57 emptyPageURL, _ = url.Parse(emptyPage.URL)58 mock012 = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {59 w.Header().Set("Content-Type", "text/html")60 w.Write([]byte(`<html><body>Last page</body></html>`))61 }))62 defer mock012.Close()63 mock012URL, _ = url.Parse(mock012.URL)64 mock011 = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {65 w.Header().Set("Content-Type", "text/html")66 w.Write([]byte(`<html><body>Last page</body></html>`))67 }))68 defer mock011.Close()69 mock011URL, _ = url.Parse(mock011.URL)70 mock01 = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {71 w.Header().Set("Content-Type", "text/html")72 w.Write([]byte(`73 <html><body>74 <a href="` + mock011.URL + `">011</a>75 <a href="` + mock012.URL + `">012</a>76 </body></html>`))77 }))78 defer mock01.Close()79 mock01URL, _ = url.Parse(mock01.URL)80 mock0 = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {81 w.Header().Set("Content-Type", "text/html")82 w.Write([]byte(`83 <html><body>84 <a href="` + mock01.URL + `">01</a>85 </body></html>`))86 }))87 defer mock0.Close()88 mock0URL, _ = url.Parse(mock0.URL)89 return m.Run()90}...

Full Screen

Full Screen

Default

Using AI Code Generation

copy

Full Screen

1import (2func handler(w http.ResponseWriter, r *http.Request) {3 fmt.Fprintf(w, "Hello, %q", html.EscapeString(r.URL.Path))4}5func main() {6 http.HandleFunc("/", handler)7 http.ListenAndServe(":8080", nil)8}9import (10func handler(w http.ResponseWriter, r *http.Request) {11 fmt.Fprintf(w, "Hello, %q", html.EscapeString(r.URL.Path))12}13func main() {14 http.HandleFunc("/", handler)15 http.ListenAndServe(":8080", nil)16}17import (18func handler(w http.ResponseWriter, r *http.Request) {19 fmt.Fprintf(w, "Hello, %q", html.EscapeString(r.URL.Path))20}21func main() {22 http.HandleFunc("/", handler)23 http.ListenAndServe(":8080", nil)24}25import (26func handler(w http.ResponseWriter, r *http.Request) {27 fmt.Fprintf(w, "Hello, %q", html.EscapeString(r.URL.Path))28}29func main() {30 http.HandleFunc("/", handler)31 http.ListenAndServe(":8080", nil)32}33import (34func handler(w http.ResponseWriter, r *http.Request) {35 fmt.Fprintf(w, "Hello, %q", html.EscapeString(r.URL.Path))36}37func main() {38 http.HandleFunc("/", handler)39 http.ListenAndServe(":8080", nil)40}41import (42func handler(w http.ResponseWriter, r *http.Request) {43 fmt.Fprintf(w, "Hello, %q", html.EscapeString(r.URL.Path))44}45func main() {46 http.HandleFunc("/",

Full Screen

Full Screen

Default

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println(html.EscapeString("This is <b>HTML</b>"))4}5import (6func main() {7 fmt.Println(html.EscapeString("This is <b>HTML</b>"))8}9import (10func main() {11 fmt.Println(html.UnescapeString("This is <b>HTML</b>"))12}13import (14func main() {15 fmt.Println(url.QueryEscape("This is <b>HTML</b>"))16}17import (18func main() {19 fmt.Println(url.QueryUnescape("This is <b>HTML</b>"))20}21import (22func main() {23 if err != nil {24 panic(err)25 }26 fmt.Println(u.Scheme)27 fmt.Println(u.User)28 fmt.Println(u.User.Username())29 p, _ := u.User.Password()30 fmt.Println(p)31 fmt.Println(u.Host)32 host, port, _ := net.SplitHostPort(u.Host)33 fmt.Println(host)34 fmt.Println(port)35 fmt.Println(u.Path)36 fmt.Println(u.RawQuery)37 m, _ := url.ParseQuery(u.RawQuery)38 fmt.Println(m)39 fmt.Println(m["q"])40 fmt.Println(m["oq"])41 fmt.Println(m["aqs"])42 fmt.Println(m["sourceid"])43 fmt.Println(m["ie"])44 fmt.Println(u.Fragment)45}46import (47func main()

Full Screen

Full Screen

Default

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println(html.EscapeString("<h1>Hello, world</h1>"))4 fmt.Println(html.UnescapeString("&lt;h1&gt;Hello, world&lt;/h1&gt;"))5}6import (7func main() {8 fmt.Println(html.EscapeString("<h1>Hello, world</h1>"))9}10import (11func main() {12 fmt.Println(html.UnescapeString("&lt;h1&gt;Hello, world&lt;/h1&gt;"))13}14import (15func main() {16 fmt.Println(html.UnescapeString("&lt;h1&gt;Hello, world&lt;/h1&gt;"))17}18import (19func main() {20 fmt.Println(html.UnescapeString("&lt;h1&gt;Hello, world&lt;/h1&gt;"))21}22import (23func main() {24 fmt.Println(html.UnescapeString("&lt;h1&gt;Hello, world&lt;/h1&gt;"))25}26import (

Full Screen

Full Screen

Default

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println(html.EscapeString("<html>"))4}5import (6func main() {7 fmt.Println(html.UnescapeString("&lt;html&gt;"))8}9import (10func main() {11 fmt.Println(html.EscapeString("<html>"))12}13import (14func main() {15 fmt.Println(html.QueryUnescape("&lt;html&gt;"))16}17import (18func main() {19 fmt.Println(html.QueryEscape("<html>"))20}21import (22func main() {23 fmt.Println(html.UnescapeString("&lt;html&gt;"))24}25import (26func main() {27 fmt.Println(html.EscapeString("<html>"))28}29import (30func main() {31 fmt.Println(html.NewDecoder(nil))32}33import (34func main() {35 fmt.Println(html.NewTokenizer(nil))36}37import (38func main() {39 fmt.Println(html.NewTokenizerString(""))40}41import (42func main() {

Full Screen

Full Screen

Default

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println(html.EscapeString("<script>alert('Hello')</script>"))4}5import (6func main() {7 fmt.Println(html.EscapeString("<script>alert('Hello')</script>"))8}9import (10func main() {11 fmt.Println(html.UnescapeString("<script>alert('Hello')</script>"))12}13&lt;script&gt;alert(&#39;Hello&#39;)&lt;/script&gt;14&lt;script&gt;alert(&#39;Hello&#39;)&lt;/script&gt;15<script>alert('Hello')</script>

Full Screen

Full Screen

Default

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println(html.EscapeString("<script>alert('Hello World!')</script>"))4 fmt.Println(html.UnescapeString("&lt;script&gt;alert(&#39;Hello World!&#39;)&lt;/script&gt;"))5}6&lt;script&gt;alert(&#39;Hello World!&#39;)&lt;/script&gt;7<script>alert('Hello World!')</script>8import (9func main() {10 fmt.Println(html.EscapeString("<script>alert('Hello World!')</script>"))11}12&lt;script&gt;alert(&#39;Hello World!&#39;)&lt;/script&gt;13import (14func main() {15 fmt.Println(html.UnescapeString("&lt;script&gt;alert(&#39;Hello World!&#39;)&lt;/script&gt;"))16}17<script>alert('Hello World!')</script>18import (19func main() {20}21import (22func main() {23 fmt.Println(html.QueryUnescape("https%3A%2F%2Fwww.google.com%2Fsearch%3Fq%3

Full Screen

Full Screen

Default

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println(html.EscapeString("This is <b>HTML</b>"))4}5import (6func main() {7 fmt.Println(html.UnescapeString("This is <b>HTML</b>"))8}9import (10func main() {11 fmt.Println(html.EscapeString("This is <b>HTML</b>"))12}13This is &lt;b&gt;HTML&lt;/b&gt;14import (15func main() {16 fmt.Println(html.UnescapeString("This is <b>HTML</b>"))17}18import (19func main() {20 fmt.Println(html.EscapeString("This is <b>HTML</b>"))21}22This is &lt;b&gt;HTML&lt;/b&gt;23import (24func main() {25 fmt.Println(html.UnescapeString("This is <b>HTML</b>"))26}27import (28func main() {29 fmt.Println(html.EscapeString("This is <b>HTML</b>"))30}31This is &lt;b&gt;HTML&lt;/b&gt;32import (33func main() {34 fmt.Println(html.UnescapeString("This is <b>HTML</b>"))35}

Full Screen

Full Screen

Default

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println(html.EscapeString(str))4}5import (6func main() {7 fmt.Println(html.EscapeString(str))8}9import (10func main() {11 fmt.Println(html.EscapeString(str))12}13import (14func main() {15 fmt.Println(html.IsBooleanAttr(str))16}17import (18func main() {19 fmt.Println(html.IsNonHTMLEscapedAttr(str))20}21import (22func main() {23 fmt.Println(html.IsSpace(str))24}25import (26func main() {27 fmt.Println(html.QueryEscape(str))28}29import (30func main() {31 fmt.Println(html.QueryUnescape(str))32}33import (34func main() {35 fmt.Println(html.UnescapeString(str))36}

Full Screen

Full Screen

Default

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println(html.EscapeString("This is <b>bold</b>"))4}5import (6func main() {7 fmt.Println(html.UnescapeString("This is &lt;b&gt;bold&lt;/b&gt;"))8}9import (10func main() {11 fmt.Println(html.EscapeString("This is <b>bold</b>"))12}13import (14func main() {15 fmt.Println(html.EscapeString("This is <b>bold</b>"))16}17import (18func main() {19 fmt.Println(html.EscapeString("This is <b>bold</b>"))20}21import (22func main() {23 fmt.Println(html.EscapeString("This is <b>bold</b>"))24}25import (26func main() {27 fmt.Println(html.EscapeString("This is <b>bold</b>"))28}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run K6 automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful