mirror of
https://github.com/NohamR/papeer.git
synced 2026-07-10 10:24:17 +00:00
update tests
This commit is contained in:
1 parent
4521497d12
commit
1b2be1c390
2 files changed
+39
-42
No files matched your search
+16
-16
@@ -19,10 +19,10 @@ func TestFilename(t *testing.T) {
|
|||||||
|
|
||||||
func TestToMarkdownString(t *testing.T) {
|
func TestToMarkdownString(t *testing.T) {
|
||||||
|
|
||||||
c := NewChapterFromURL("https://12factor.net/", "", []*ScrapeConfig{NewScrapeConfig()}, 0, func(index int, name string) {})
|
c := NewChapterFromURL("https://example.com/", "", []*ScrapeConfig{NewScrapeConfig()}, 0, func(index int, name string) {})
|
||||||
|
|
||||||
got := ToMarkdownString(c)
|
got := ToMarkdownString(c)
|
||||||
want := "The Twelve-Factor App\n=====================\n\nIn the modern era, software is commonly delivered as a service: called _web apps_, or _software-as-a-service_. The twelve-factor app is a methodology for building software-as-a-service apps that:\n\n- Use **declarative** formats for setup automation, to minimize time and cost for new developers joining the project;\n- Have a **clean contract** with the underlying operating system, offering **maximum portability** between execution environments;\n- Are suitable for **deployment** on modern **cloud platforms**, obviating the need for servers and systems administration;\n- **Minimize divergence** between development and production, enabling **continuous deployment** for maximum agility;\n- And can **scale up** without significant changes to tooling, architecture, or development practices.\n\nThe twelve-factor methodology can be applied to apps written in any programming language, and which use any combination of backing services (database, queue, memory cache, etc).\n\nThe contributors to this document have been directly involved in the development and deployment of hundreds of apps, and indirectly witnessed the development, operation, and scaling of hundreds of thousands of apps via our work on the [Heroku](http://www.heroku.com/) platform.\n\nThis document synthesizes all of our experience and observations on a wide variety of software-as-a-service apps in the wild. It is a triangulation on ideal practices for app development, paying particular attention to the dynamics of the organic growth of an app over time, the dynamics of collaboration between developers working on the app’s codebase, and [avoiding the cost of software erosion](http://blog.heroku.com/archives/2011/6/28/the_new_heroku_4_erosion_resistance_explicit_contracts/).\n\nOur motivation is to raise awareness of some systemic problems we’ve seen in modern application development, to provide a shared vocabulary for discussing those problems, and to offer a set of broad conceptual solutions to those problems with accompanying terminology. The format is inspired by Martin Fowler’s books _[Patterns of Enterprise Application Architecture](https://books.google.com/books/about/Patterns_of_enterprise_application_archi.html?id=FyWZt5DdvFkC)_ and _[Refactoring](https://books.google.com/books/about/Refactoring.html?id=1MsETFPD3I0C)_.\n\nAny developer building applications which run as a service. Ops engineers who deploy or manage such applications.\n\n## [I. Codebase](https://12factor.net/codebase)\n\n### One codebase tracked in revision control, many deploys\n\n## [II. Dependencies](https://12factor.net/dependencies)\n\n### Explicitly declare and isolate dependencies\n\n## [III. Config](https://12factor.net/config)\n\n### Store config in the environment\n\n## [IV. Backing services](https://12factor.net/backing-services)\n\n### Treat backing services as attached resources\n\n## [V. Build, release, run](https://12factor.net/build-release-run)\n\n### Strictly separate build and run stages\n\n## [VI. Processes](https://12factor.net/processes)\n\n### Execute the app as one or more stateless processes\n\n## [VII. Port binding](https://12factor.net/port-binding)\n\n### Export services via port binding\n\n## [VIII. Concurrency](https://12factor.net/concurrency)\n\n### Scale out via the process model\n\n## [IX. Disposability](https://12factor.net/disposability)\n\n### Maximize robustness with fast startup and graceful shutdown\n\n## [X. Dev/prod parity](https://12factor.net/dev-prod-parity)\n\n### Keep development, staging, and production as similar as possible\n\n## [XI. Logs](https://12factor.net/logs)\n\n### Treat logs as event streams\n\n## [XII. Admin processes](https://12factor.net/admin-processes)\n\n### Run admin/management tasks as one-off processes\n\n\n"
|
want := "Example Domain\n==============\n\nThis domain is for use in illustrative examples in documents. You may use this\ndomain in literature without prior coordination or asking for permission.\n\n[More information...](https://www.iana.org/domains/example)\n\n\n"
|
||||||
|
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("got %q, wanted %q", got, want)
|
t.Errorf("got %q, wanted %q", got, want)
|
||||||
@@ -32,10 +32,10 @@ func TestToMarkdownString(t *testing.T) {
|
|||||||
|
|
||||||
func TestToMarkdown(t *testing.T) {
|
func TestToMarkdown(t *testing.T) {
|
||||||
|
|
||||||
c := NewChapterFromURL("https://12factor.net/", "", []*ScrapeConfig{NewScrapeConfig()}, 0, func(index int, name string) {})
|
c := NewChapterFromURL("https://example.com/", "", []*ScrapeConfig{NewScrapeConfig()}, 0, func(index int, name string) {})
|
||||||
ToMarkdown(c, "")
|
ToMarkdown(c, "")
|
||||||
|
|
||||||
filename := "The_Twelve-Factor_App.md"
|
filename := "Example_Domain.md"
|
||||||
if _, err := os.Stat(filename); errors.Is(err, os.ErrNotExist) {
|
if _, err := os.Stat(filename); errors.Is(err, os.ErrNotExist) {
|
||||||
t.Errorf("%s does not exist: %v", filename, err)
|
t.Errorf("%s does not exist: %v", filename, err)
|
||||||
} else {
|
} else {
|
||||||
@@ -49,7 +49,7 @@ func TestToMarkdown(t *testing.T) {
|
|||||||
func TestToMarkdownFilename(t *testing.T) {
|
func TestToMarkdownFilename(t *testing.T) {
|
||||||
|
|
||||||
filename := "ebook.md"
|
filename := "ebook.md"
|
||||||
c := NewChapterFromURL("https://12factor.net/", "", []*ScrapeConfig{NewScrapeConfig()}, 0, func(index int, name string) {})
|
c := NewChapterFromURL("https://example.com/", "", []*ScrapeConfig{NewScrapeConfig()}, 0, func(index int, name string) {})
|
||||||
ToMarkdown(c, filename)
|
ToMarkdown(c, filename)
|
||||||
|
|
||||||
if _, err := os.Stat(filename); errors.Is(err, os.ErrNotExist) {
|
if _, err := os.Stat(filename); errors.Is(err, os.ErrNotExist) {
|
||||||
@@ -64,10 +64,10 @@ func TestToMarkdownFilename(t *testing.T) {
|
|||||||
|
|
||||||
func TestToHtmlString(t *testing.T) {
|
func TestToHtmlString(t *testing.T) {
|
||||||
|
|
||||||
c := NewChapterFromURL("https://12factor.net/", "", []*ScrapeConfig{NewScrapeConfig()}, 0, func(index int, name string) {})
|
c := NewChapterFromURL("https://example.com/", "", []*ScrapeConfig{NewScrapeConfig()}, 0, func(index int, name string) {})
|
||||||
|
|
||||||
got := ToHtmlString(c)
|
got := ToHtmlString(c)
|
||||||
want := "<h1>The Twelve-Factor App</h1>\n \n\n <header>\n \n </header>\n\n <section>\n <article>\n\n\n<p>In the modern era, software is commonly delivered as a service: called <em>web apps</em>, or <em>software-as-a-service</em>. The twelve-factor app is a methodology for building software-as-a-service apps that:</p>\n\n<ul>\n<li>Use <strong>declarative</strong> formats for setup automation, to minimize time and cost for new developers joining the project;</li>\n\n<li>Have a <strong>clean contract</strong> with the underlying operating system, offering <strong>maximum portability</strong> between execution environments;</li>\n\n<li>Are suitable for <strong>deployment</strong> on modern <strong>cloud platforms</strong>, obviating the need for servers and systems administration;</li>\n\n<li><strong>Minimize divergence</strong> between development and production, enabling <strong>continuous deployment</strong> for maximum agility;</li>\n\n<li>And can <strong>scale up</strong> without significant changes to tooling, architecture, or development practices.</li>\n</ul>\n\n<p>The twelve-factor methodology can be applied to apps written in any programming language, and which use any combination of backing services (database, queue, memory cache, etc).</p>\n</article>\n <article>\n\n\n<p>The contributors to this document have been directly involved in the development and deployment of hundreds of apps, and indirectly witnessed the development, operation, and scaling of hundreds of thousands of apps via our work on the <a href=\"http://www.heroku.com/\" target=\"_blank\">Heroku</a> platform.</p>\n\n<p>This document synthesizes all of our experience and observations on a wide variety of software-as-a-service apps in the wild. It is a triangulation on ideal practices for app development, paying particular attention to the dynamics of the organic growth of an app over time, the dynamics of collaboration between developers working on the app’s codebase, and <a href=\"http://blog.heroku.com/archives/2011/6/28/the_new_heroku_4_erosion_resistance_explicit_contracts/\" target=\"_blank\">avoiding the cost of software erosion</a>.</p>\n\n<p>Our motivation is to raise awareness of some systemic problems we’ve seen in modern application development, to provide a shared vocabulary for discussing those problems, and to offer a set of broad conceptual solutions to those problems with accompanying terminology. The format is inspired by Martin Fowler’s books <em><a href=\"https://books.google.com/books/about/Patterns_of_enterprise_application_archi.html?id=FyWZt5DdvFkC\" target=\"_blank\">Patterns of Enterprise Application Architecture</a></em> and <em><a href=\"https://books.google.com/books/about/Refactoring.html?id=1MsETFPD3I0C\" target=\"_blank\">Refactoring</a></em>.</p>\n</article>\n <article>\n\n\n<p>Any developer building applications which run as a service. Ops engineers who deploy or manage such applications.</p>\n</article>\n</section>\n\n<section>\n <article>\n\n\n<h2 id=\"i_codebase\"><a href=\"https://12factor.net/codebase\">I. Codebase</a></h2>\n\n<h3 id=\"one_codebase_tracked_in_revision_control_many_deploys\">One codebase tracked in revision control, many deploys</h3>\n\n<h2 id=\"ii_dependencies\"><a href=\"https://12factor.net/dependencies\">II. Dependencies</a></h2>\n\n<h3 id=\"explicitly_declare_and_isolate_dependencies\">Explicitly declare and isolate dependencies</h3>\n\n<h2 id=\"iii_config\"><a href=\"https://12factor.net/config\">III. Config</a></h2>\n\n<h3 id=\"store_config_in_the_environment\">Store config in the environment</h3>\n\n<h2 id=\"iv_backing_services\"><a href=\"https://12factor.net/backing-services\">IV. Backing services</a></h2>\n\n<h3 id=\"treat_backing_services_as_attached_resources\">Treat backing services as attached resources</h3>\n\n<h2 id=\"v_build_release_run\"><a href=\"https://12factor.net/build-release-run\">V. Build, release, run</a></h2>\n\n<h3 id=\"strictly_separate_build_and_run_stages\">Strictly separate build and run stages</h3>\n\n<h2 id=\"vi_processes\"><a href=\"https://12factor.net/processes\">VI. Processes</a></h2>\n\n<h3 id=\"execute_the_app_as_one_or_more_stateless_processes\">Execute the app as one or more stateless processes</h3>\n\n<h2 id=\"vii_port_binding\"><a href=\"https://12factor.net/port-binding\">VII. Port binding</a></h2>\n\n<h3 id=\"export_services_via_port_binding\">Export services via port binding</h3>\n\n<h2 id=\"viii_concurrency\"><a href=\"https://12factor.net/concurrency\">VIII. Concurrency</a></h2>\n\n<h3 id=\"scale_out_via_the_process_model\">Scale out via the process model</h3>\n\n<h2 id=\"ix_disposability\"><a href=\"https://12factor.net/disposability\">IX. Disposability</a></h2>\n\n<h3 id=\"maximize_robustness_with_fast_startup_and_graceful_shutdown\">Maximize robustness with fast startup and graceful shutdown</h3>\n\n<h2 id=\"x_devprod_parity\"><a href=\"https://12factor.net/dev-prod-parity\">X. Dev/prod parity</a></h2>\n\n<h3 iLine truncated
|
want := "<h1>Example Domain</h1><div>\n \n <p>This domain is for use in illustrative examples in documents. You may use this\n domain in literature without prior coordination or asking for permission.</p>\n <p><a href=\"https://www.iana.org/domains/example\">More information...</a></p>\n</div>"
|
||||||
|
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("got %q, wanted %q", got, want)
|
t.Errorf("got %q, wanted %q", got, want)
|
||||||
@@ -77,10 +77,10 @@ func TestToHtmlString(t *testing.T) {
|
|||||||
|
|
||||||
func TestToHtml(t *testing.T) {
|
func TestToHtml(t *testing.T) {
|
||||||
|
|
||||||
c := NewChapterFromURL("https://12factor.net/", "", []*ScrapeConfig{NewScrapeConfig()}, 0, func(index int, name string) {})
|
c := NewChapterFromURL("https://example.com/", "", []*ScrapeConfig{NewScrapeConfig()}, 0, func(index int, name string) {})
|
||||||
ToHtml(c, "")
|
ToHtml(c, "")
|
||||||
|
|
||||||
filename := "The_Twelve-Factor_App.html"
|
filename := "Example_Domain.html"
|
||||||
if _, err := os.Stat(filename); errors.Is(err, os.ErrNotExist) {
|
if _, err := os.Stat(filename); errors.Is(err, os.ErrNotExist) {
|
||||||
t.Errorf("%s does not exist: %v", filename, err)
|
t.Errorf("%s does not exist: %v", filename, err)
|
||||||
} else {
|
} else {
|
||||||
@@ -94,7 +94,7 @@ func TestToHtml(t *testing.T) {
|
|||||||
func TestToHtmlFilename(t *testing.T) {
|
func TestToHtmlFilename(t *testing.T) {
|
||||||
|
|
||||||
filename := "ebook.html"
|
filename := "ebook.html"
|
||||||
c := NewChapterFromURL("https://12factor.net/", "", []*ScrapeConfig{NewScrapeConfig()}, 0, func(index int, name string) {})
|
c := NewChapterFromURL("https://example.com/", "", []*ScrapeConfig{NewScrapeConfig()}, 0, func(index int, name string) {})
|
||||||
ToHtml(c, filename)
|
ToHtml(c, filename)
|
||||||
|
|
||||||
if _, err := os.Stat(filename); errors.Is(err, os.ErrNotExist) {
|
if _, err := os.Stat(filename); errors.Is(err, os.ErrNotExist) {
|
||||||
@@ -109,10 +109,10 @@ func TestToHtmlFilename(t *testing.T) {
|
|||||||
|
|
||||||
func TestToEpub(t *testing.T) {
|
func TestToEpub(t *testing.T) {
|
||||||
|
|
||||||
c := NewChapterFromURL("https://12factor.net/", "", []*ScrapeConfig{NewScrapeConfig()}, 0, func(index int, name string) {})
|
c := NewChapterFromURL("https://example.com/", "", []*ScrapeConfig{NewScrapeConfig()}, 0, func(index int, name string) {})
|
||||||
ToEpub(c, "")
|
ToEpub(c, "")
|
||||||
|
|
||||||
filename := "The_Twelve-Factor_App.epub"
|
filename := "Example_Domain.epub"
|
||||||
if _, err := os.Stat(filename); errors.Is(err, os.ErrNotExist) {
|
if _, err := os.Stat(filename); errors.Is(err, os.ErrNotExist) {
|
||||||
t.Errorf("%s does not exist: %v", filename, err)
|
t.Errorf("%s does not exist: %v", filename, err)
|
||||||
} else {
|
} else {
|
||||||
@@ -126,7 +126,7 @@ func TestToEpub(t *testing.T) {
|
|||||||
func TestToEpubFilename(t *testing.T) {
|
func TestToEpubFilename(t *testing.T) {
|
||||||
|
|
||||||
filename := "ebook.epub"
|
filename := "ebook.epub"
|
||||||
c := NewChapterFromURL("https://12factor.net/", "", []*ScrapeConfig{NewScrapeConfig()}, 0, func(index int, name string) {})
|
c := NewChapterFromURL("https://example.com/", "", []*ScrapeConfig{NewScrapeConfig()}, 0, func(index int, name string) {})
|
||||||
ToEpub(c, filename)
|
ToEpub(c, filename)
|
||||||
|
|
||||||
if _, err := os.Stat(filename); errors.Is(err, os.ErrNotExist) {
|
if _, err := os.Stat(filename); errors.Is(err, os.ErrNotExist) {
|
||||||
@@ -141,10 +141,10 @@ func TestToEpubFilename(t *testing.T) {
|
|||||||
|
|
||||||
func TestToMobi(t *testing.T) {
|
func TestToMobi(t *testing.T) {
|
||||||
|
|
||||||
c := NewChapterFromURL("https://12factor.net/", "", []*ScrapeConfig{NewScrapeConfig()}, 0, func(index int, name string) {})
|
c := NewChapterFromURL("https://example.com/", "", []*ScrapeConfig{NewScrapeConfig()}, 0, func(index int, name string) {})
|
||||||
ToMobi(c, "")
|
ToMobi(c, "")
|
||||||
|
|
||||||
filename := "The_Twelve-Factor_App.mobi"
|
filename := "Example_Domain.mobi"
|
||||||
if _, err := os.Stat(filename); errors.Is(err, os.ErrNotExist) {
|
if _, err := os.Stat(filename); errors.Is(err, os.ErrNotExist) {
|
||||||
t.Errorf("%s does not exist: %v", filename, err)
|
t.Errorf("%s does not exist: %v", filename, err)
|
||||||
} else {
|
} else {
|
||||||
@@ -158,7 +158,7 @@ func TestToMobi(t *testing.T) {
|
|||||||
func TestToMobiFilename(t *testing.T) {
|
func TestToMobiFilename(t *testing.T) {
|
||||||
|
|
||||||
filename := "ebook.mobi"
|
filename := "ebook.mobi"
|
||||||
c := NewChapterFromURL("https://12factor.net/", "", []*ScrapeConfig{NewScrapeConfig()}, 0, func(index int, name string) {})
|
c := NewChapterFromURL("https://example.com/", "", []*ScrapeConfig{NewScrapeConfig()}, 0, func(index int, name string) {})
|
||||||
ToMobi(c, filename)
|
ToMobi(c, filename)
|
||||||
|
|
||||||
if _, err := os.Stat(filename); errors.Is(err, os.ErrNotExist) {
|
if _, err := os.Stat(filename); errors.Is(err, os.ErrNotExist) {
|
||||||
|
|||||||
+23
-26
@@ -8,10 +8,10 @@ import (
|
|||||||
func TestBody(t *testing.T) {
|
func TestBody(t *testing.T) {
|
||||||
|
|
||||||
config := NewScrapeConfig()
|
config := NewScrapeConfig()
|
||||||
c := NewChapterFromURL("https://12factor.net/", "", []*ScrapeConfig{config}, 0, func(index int, name string) {})
|
c := NewChapterFromURL("https://example.com/", "", []*ScrapeConfig{config}, 0, func(index int, name string) {})
|
||||||
|
|
||||||
got := c.Body()
|
got := c.Body()
|
||||||
want := "<!doctype html>\n<html lang=\"en\">\n<head>\n <meta charset=\"utf-8\">\n\n <title>The Twelve-Factor App </title>\n <meta name=\"description\" content=\"A methodology for building modern, scalable, maintainable software-as-a-service apps.\">\n <meta name=\"author\" content=\"Adam Wiggins\">\n\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <link rel=\"shortcut icon\" href=\"images/favicon.ico\">\n\n <link rel=\"stylesheet\" href=\"/css/screen.css\" media=\"screen\">\n <link rel=\"stylesheet\" href=\"/css/mobile.css\" media=\"screen\">\n\n <script type=\"text/javascript\" src=\"//use.typekit.com/rsq7tro.js\"></script>\n <script type=\"text/javascript\">try{Typekit.load();}catch(e){}</script>\n</head>\n<body>\n \n\n <header>\n <h1><a href=\"./\" title=\"The Twelve-Factor App\">The Twelve-Factor App</a></h1>\n </header>\n\n <section class=\"abstract\">\n <article>\n<h1 id=\"introduction\">Introduction</h1>\n\n<p>In the modern era, software is commonly delivered as a service: called <em>web apps</em>, or <em>software-as-a-service</em>. The twelve-factor app is a methodology for building software-as-a-service apps that:</p>\n\n<ul>\n<li>Use <strong>declarative</strong> formats for setup automation, to minimize time and cost for new developers joining the project;</li>\n\n<li>Have a <strong>clean contract</strong> with the underlying operating system, offering <strong>maximum portability</strong> between execution environments;</li>\n\n<li>Are suitable for <strong>deployment</strong> on modern <strong>cloud platforms</strong>, obviating the need for servers and systems administration;</li>\n\n<li><strong>Minimize divergence</strong> between development and production, enabling <strong>continuous deployment</strong> for maximum agility;</li>\n\n<li>And can <strong>scale up</strong> without significant changes to tooling, architecture, or development practices.</li>\n</ul>\n\n<p>The twelve-factor methodology can be applied to apps written in any programming language, and which use any combination of backing services (database, queue, memory cache, etc).</p>\n</article>\n <article>\n<h1 id=\"background\">Background</h1>\n\n<p>The contributors to this document have been directly involved in the development and deployment of hundreds of apps, and indirectly witnessed the development, operation, and scaling of hundreds of thousands of apps via our work on the <a href='http://www.heroku.com/' target='_blank'>Heroku</a> platform.</p>\n\n<p>This document synthesizes all of our experience and observations on a wide variety of software-as-a-service apps in the wild. It is a triangulation on ideal practices for app development, paying particular attention to the dynamics of the organic growth of an app over time, the dynamics of collaboration between developers working on the app’s codebase, and <a href='http://blog.heroku.com/archives/2011/6/28/the_new_heroku_4_erosion_resistance_explicit_contracts/' target='_blank'>avoiding the cost of software erosion</a>.</p>\n\n<p>Our motivation is to raise awareness of some systemic problems we’ve seen in modern application development, to provide a shared vocabulary for discussing those problems, and to offer a set of broad conceptual solutions to those problems with accompanying terminology. The format is inspired by Martin Fowler’s books <em><a href='https://books.google.com/books/about/Patterns_of_enterprise_application_archi.html?id=FyWZt5DdvFkC' target='_blank'>Patterns of Enterprise Application Architecture</a></em> and <em><a href='https://books.google.com/books/about/Refactoring.html?id=1MsETFPD3I0C' target='_blank'>Refactoring</a></em>.</p>\n</article>\n <article>\n<h1 id=\"who_should_read_this_document\">Who should read this document?</h1>\n\n<p>Any developer building applications which run as a service. Ops engineers who deploy or manage such applications.</p>\n</article>\n</section>\n\n<section class=\"concrete\">\n <article>\n<h1 id=\"the_twelve_factors\">The Twelve Factors</h1>\n\n<h2 id=\"i_codebase\"><a href=\"./codebase\">I. Codebase</a></h2>\n\n<h3 id=\"one_codebase_tracked_in_revision_control_many_deploys\">One codebase tracked in revision control, many deploys</h3>\n\n<h2 id=\"ii_dependencies\"><a href=\"./dependencies\">II. Dependencies</a></h2>\n\n<h3 id=\"explicitly_declare_and_isolate_dependencies\">Explicitly declare and isolate dependencies</h3>\n\n<h2 id=\"iii_config\"><a href=\"./config\">III. Config</a></h2>\n\n<h3 id=\"store_config_in_the_environment\">Store config in the environment</h3>\n\n<h2 id=\"iv_backing_services\"><a href=\"./backing-services\">IV. Backing services</a></h2>\n\n<h3 id=\"treat_backing_services_as_attached_resources\">Treat backing services as attached resources</h3>\n\n<h2 id=\"v_build_release_run\"><a href=\"./build-release-run\">V. Build, release, run</a></h2>\n\n<h3 id=\"strictly_separate_build_and_run_stages\">Strictly separate build and run stages</h3>\n\n<h2 iLine truncated
|
want := "<!doctype html>\n<html>\n<head>\n <title>Example Domain</title>\n\n <meta charset=\"utf-8\" />\n <meta http-equiv=\"Content-type\" content=\"text/html; charset=utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n <style type=\"text/css\">\n body {\n background-color: #f0f0f2;\n margin: 0;\n padding: 0;\n font-family: -apple-system, system-ui, BlinkMacSystemFont, \"Segoe UI\", \"Open Sans\", \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n \n }\n div {\n width: 600px;\n margin: 5em auto;\n padding: 2em;\n background-color: #fdfdff;\n border-radius: 0.5em;\n box-shadow: 2px 3px 7px 2px rgba(0,0,0,0.02);\n }\n a:link, a:visited {\n color: #38488f;\n text-decoration: none;\n }\n @media (max-width: 700px) {\n div {\n margin: 0 auto;\n width: auto;\n }\n }\n </style> \n</head>\n\n<body>\n<div>\n <h1>Example Domain</h1>\n <p>This domain is for use in illustrative examples in documents. You may use this\n domain in literature without prior coordination or asking for permission.</p>\n <p><a href=\"https://www.iana.org/domains/example\">More information...</a></p>\n</div>\n</body>\n</html>\n"
|
||||||
|
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("got %v, wanted %v", got, want)
|
t.Errorf("got %v, wanted %v", got, want)
|
||||||
@@ -22,10 +22,10 @@ func TestBody(t *testing.T) {
|
|||||||
func TestName(t *testing.T) {
|
func TestName(t *testing.T) {
|
||||||
|
|
||||||
config := NewScrapeConfig()
|
config := NewScrapeConfig()
|
||||||
c := NewChapterFromURL("https://12factor.net/", "", []*ScrapeConfig{config}, 0, func(index int, name string) {})
|
c := NewChapterFromURL("https://example.com/", "", []*ScrapeConfig{config}, 0, func(index int, name string) {})
|
||||||
|
|
||||||
got := c.Name()
|
got := c.Name()
|
||||||
want := "The Twelve-Factor App"
|
want := "Example Domain"
|
||||||
|
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("got %v, wanted %v", got, want)
|
t.Errorf("got %v, wanted %v", got, want)
|
||||||
@@ -37,7 +37,7 @@ func TestCustomName(t *testing.T) {
|
|||||||
|
|
||||||
config := NewScrapeConfig()
|
config := NewScrapeConfig()
|
||||||
config.UseLinkName = true
|
config.UseLinkName = true
|
||||||
c := NewChapterFromURL("https://12factor.net/", "Custom Name", []*ScrapeConfig{config}, 0, func(index int, name string) {})
|
c := NewChapterFromURL("https://example.com/", "Custom Name", []*ScrapeConfig{config}, 0, func(index int, name string) {})
|
||||||
|
|
||||||
got := c.Name()
|
got := c.Name()
|
||||||
want := "Custom Name"
|
want := "Custom Name"
|
||||||
@@ -65,10 +65,10 @@ func TestAuthor(t *testing.T) {
|
|||||||
func TestContent(t *testing.T) {
|
func TestContent(t *testing.T) {
|
||||||
|
|
||||||
config := NewScrapeConfig()
|
config := NewScrapeConfig()
|
||||||
c := NewChapterFromURL("https://12factor.net/", "", []*ScrapeConfig{config}, 0, func(index int, name string) {})
|
c := NewChapterFromURL("https://example.com/", "", []*ScrapeConfig{config}, 0, func(index int, name string) {})
|
||||||
|
|
||||||
got := c.Content()
|
got := c.Content()
|
||||||
want := "\n \n\n <header>\n \n </header>\n\n <section>\n <article>\n\n\n<p>In the modern era, software is commonly delivered as a service: called <em>web apps</em>, or <em>software-as-a-service</em>. The twelve-factor app is a methodology for building software-as-a-service apps that:</p>\n\n<ul>\n<li>Use <strong>declarative</strong> formats for setup automation, to minimize time and cost for new developers joining the project;</li>\n\n<li>Have a <strong>clean contract</strong> with the underlying operating system, offering <strong>maximum portability</strong> between execution environments;</li>\n\n<li>Are suitable for <strong>deployment</strong> on modern <strong>cloud platforms</strong>, obviating the need for servers and systems administration;</li>\n\n<li><strong>Minimize divergence</strong> between development and production, enabling <strong>continuous deployment</strong> for maximum agility;</li>\n\n<li>And can <strong>scale up</strong> without significant changes to tooling, architecture, or development practices.</li>\n</ul>\n\n<p>The twelve-factor methodology can be applied to apps written in any programming language, and which use any combination of backing services (database, queue, memory cache, etc).</p>\n</article>\n <article>\n\n\n<p>The contributors to this document have been directly involved in the development and deployment of hundreds of apps, and indirectly witnessed the development, operation, and scaling of hundreds of thousands of apps via our work on the <a href=\"http://www.heroku.com/\" target=\"_blank\">Heroku</a> platform.</p>\n\n<p>This document synthesizes all of our experience and observations on a wide variety of software-as-a-service apps in the wild. It is a triangulation on ideal practices for app development, paying particular attention to the dynamics of the organic growth of an app over time, the dynamics of collaboration between developers working on the app’s codebase, and <a href=\"http://blog.heroku.com/archives/2011/6/28/the_new_heroku_4_erosion_resistance_explicit_contracts/\" target=\"_blank\">avoiding the cost of software erosion</a>.</p>\n\n<p>Our motivation is to raise awareness of some systemic problems we’ve seen in modern application development, to provide a shared vocabulary for discussing those problems, and to offer a set of broad conceptual solutions to those problems with accompanying terminology. The format is inspired by Martin Fowler’s books <em><a href=\"https://books.google.com/books/about/Patterns_of_enterprise_application_archi.html?id=FyWZt5DdvFkC\" target=\"_blank\">Patterns of Enterprise Application Architecture</a></em> and <em><a href=\"https://books.google.com/books/about/Refactoring.html?id=1MsETFPD3I0C\" target=\"_blank\">Refactoring</a></em>.</p>\n</article>\n <article>\n\n\n<p>Any developer building applications which run as a service. Ops engineers who deploy or manage such applications.</p>\n</article>\n</section>\n\n<section>\n <article>\n\n\n<h2 id=\"i_codebase\"><a href=\"https://12factor.net/codebase\">I. Codebase</a></h2>\n\n<h3 id=\"one_codebase_tracked_in_revision_control_many_deploys\">One codebase tracked in revision control, many deploys</h3>\n\n<h2 id=\"ii_dependencies\"><a href=\"https://12factor.net/dependencies\">II. Dependencies</a></h2>\n\n<h3 id=\"explicitly_declare_and_isolate_dependencies\">Explicitly declare and isolate dependencies</h3>\n\n<h2 id=\"iii_config\"><a href=\"https://12factor.net/config\">III. Config</a></h2>\n\n<h3 id=\"store_config_in_the_environment\">Store config in the environment</h3>\n\n<h2 id=\"iv_backing_services\"><a href=\"https://12factor.net/backing-services\">IV. Backing services</a></h2>\n\n<h3 id=\"treat_backing_services_as_attached_resources\">Treat backing services as attached resources</h3>\n\n<h2 id=\"v_build_release_run\"><a href=\"https://12factor.net/build-release-run\">V. Build, release, run</a></h2>\n\n<h3 id=\"strictly_separate_build_and_run_stages\">Strictly separate build and run stages</h3>\n\n<h2 id=\"vi_processes\"><a href=\"https://12factor.net/processes\">VI. Processes</a></h2>\n\n<h3 id=\"execute_the_app_as_one_or_more_stateless_processes\">Execute the app as one or more stateless processes</h3>\n\n<h2 id=\"vii_port_binding\"><a href=\"https://12factor.net/port-binding\">VII. Port binding</a></h2>\n\n<h3 id=\"export_services_via_port_binding\">Export services via port binding</h3>\n\n<h2 id=\"viii_concurrency\"><a href=\"https://12factor.net/concurrency\">VIII. Concurrency</a></h2>\n\n<h3 id=\"scale_out_via_the_process_model\">Scale out via the process model</h3>\n\n<h2 id=\"ix_disposability\"><a href=\"https://12factor.net/disposability\">IX. Disposability</a></h2>\n\n<h3 id=\"maximize_robustness_with_fast_startup_and_graceful_shutdown\">Maximize robustness with fast startup and graceful shutdown</h3>\n\n<h2 id=\"x_devprod_parity\"><a href=\"https://12factor.net/dev-prod-parity\">X. Dev/prod parity</a></h2>\n\n<h3 id=\"keep_development_staging_aLine truncated
|
want := "<div>\n \n <p>This domain is for use in illustrative examples in documents. You may use this\n domain in literature without prior coordination or asking for permission.</p>\n <p><a href=\"https://www.iana.org/domains/example\">More information...</a></p>\n</div>"
|
||||||
|
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("got %v, wanted %v", got, want)
|
t.Errorf("got %v, wanted %v", got, want)
|
||||||
@@ -84,7 +84,7 @@ func TestDelay(t *testing.T) {
|
|||||||
config1 := NewScrapeConfig()
|
config1 := NewScrapeConfig()
|
||||||
|
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
NewChapterFromURL("https://12factor.net/", "", []*ScrapeConfig{config0, config1}, 0, func(index int, name string) {})
|
NewChapterFromURL("https://example.com/", "", []*ScrapeConfig{config0, config1}, 0, func(index int, name string) {})
|
||||||
elapsed := time.Since(start)
|
elapsed := time.Since(start)
|
||||||
|
|
||||||
got := elapsed
|
got := elapsed
|
||||||
@@ -117,10 +117,10 @@ func TestSubChapters(t *testing.T) {
|
|||||||
config0 := NewScrapeConfig()
|
config0 := NewScrapeConfig()
|
||||||
config1 := NewScrapeConfig()
|
config1 := NewScrapeConfig()
|
||||||
|
|
||||||
c := NewChapterFromURL("https://atomicdesign.bradfrost.com/table-of-contents/", "", []*ScrapeConfig{config0, config1}, 0, func(index int, name string) {})
|
c := NewChapterFromURL("https://html5example.com/", "", []*ScrapeConfig{config0, config1}, 0, func(index int, name string) {})
|
||||||
|
|
||||||
got := len(c.SubChapters())
|
got := len(c.SubChapters())
|
||||||
want := 9
|
want := 14
|
||||||
|
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("got %v, wanted %v", got, want)
|
t.Errorf("got %v, wanted %v", got, want)
|
||||||
@@ -136,7 +136,7 @@ func TestSubChaptersRSS(t *testing.T) {
|
|||||||
c := NewChapterFromURL("https://www.nginx.com/feed/", "", []*ScrapeConfig{config0, config1}, 0, func(index int, name string) {})
|
c := NewChapterFromURL("https://www.nginx.com/feed/", "", []*ScrapeConfig{config0, config1}, 0, func(index int, name string) {})
|
||||||
|
|
||||||
got := len(c.SubChapters())
|
got := len(c.SubChapters())
|
||||||
want := 10
|
want := 14
|
||||||
|
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("got %v, wanted %v", got, want)
|
t.Errorf("got %v, wanted %v", got, want)
|
||||||
@@ -147,14 +147,14 @@ func TestSubChaptersRSS(t *testing.T) {
|
|||||||
func TestSubChaptersSelector(t *testing.T) {
|
func TestSubChaptersSelector(t *testing.T) {
|
||||||
|
|
||||||
config0 := NewScrapeConfig()
|
config0 := NewScrapeConfig()
|
||||||
config0.Selector = "section.concrete > article > h2 > a"
|
config0.Selector = "body > aside > p > a"
|
||||||
|
|
||||||
config1 := NewScrapeConfig()
|
config1 := NewScrapeConfig()
|
||||||
|
|
||||||
c := NewChapterFromURL("https://12factor.net/", "", []*ScrapeConfig{config0, config1}, 0, func(index int, name string) {})
|
c := NewChapterFromURL("https://html5example.com/", "", []*ScrapeConfig{config0, config1}, 0, func(index int, name string) {})
|
||||||
|
|
||||||
got := len(c.SubChapters())
|
got := len(c.SubChapters())
|
||||||
want := 12
|
want := 14
|
||||||
|
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("got %v, wanted %v", got, want)
|
t.Errorf("got %v, wanted %v", got, want)
|
||||||
@@ -165,15 +165,14 @@ func TestSubChaptersSelector(t *testing.T) {
|
|||||||
func TestSubChaptersLimit(t *testing.T) {
|
func TestSubChaptersLimit(t *testing.T) {
|
||||||
|
|
||||||
config0 := NewScrapeConfig()
|
config0 := NewScrapeConfig()
|
||||||
config0.Selector = "section.concrete > article > h2 > a"
|
config0.Limit = 1
|
||||||
config0.Limit = 2
|
|
||||||
|
|
||||||
config1 := NewScrapeConfig()
|
config1 := NewScrapeConfig()
|
||||||
|
|
||||||
c := NewChapterFromURL("https://12factor.net/", "", []*ScrapeConfig{config0, config1}, 0, func(index int, name string) {})
|
c := NewChapterFromURL("https://html5example.com/", "", []*ScrapeConfig{config0, config1}, 0, func(index int, name string) {})
|
||||||
|
|
||||||
got := len(c.SubChapters())
|
got := len(c.SubChapters())
|
||||||
want := 2
|
want := 1
|
||||||
|
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("got %v, wanted %v", got, want)
|
t.Errorf("got %v, wanted %v", got, want)
|
||||||
@@ -184,15 +183,14 @@ func TestSubChaptersLimit(t *testing.T) {
|
|||||||
func TestSubChaptersLimitOver(t *testing.T) {
|
func TestSubChaptersLimitOver(t *testing.T) {
|
||||||
|
|
||||||
config0 := NewScrapeConfig()
|
config0 := NewScrapeConfig()
|
||||||
config0.Selector = "section.concrete > article > h2 > a"
|
config0.Limit = 15
|
||||||
config0.Limit = 13
|
|
||||||
|
|
||||||
config1 := NewScrapeConfig()
|
config1 := NewScrapeConfig()
|
||||||
|
|
||||||
c := NewChapterFromURL("https://12factor.net/", "", []*ScrapeConfig{config0, config1}, 0, func(index int, name string) {})
|
c := NewChapterFromURL("https://html5example.com/", "", []*ScrapeConfig{config0, config1}, 0, func(index int, name string) {})
|
||||||
|
|
||||||
got := len(c.SubChapters())
|
got := len(c.SubChapters())
|
||||||
want := 12
|
want := 14
|
||||||
|
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("got %v, wanted %v", got, want)
|
t.Errorf("got %v, wanted %v", got, want)
|
||||||
@@ -207,10 +205,10 @@ func TestReverse(t *testing.T) {
|
|||||||
|
|
||||||
config1 := NewScrapeConfig()
|
config1 := NewScrapeConfig()
|
||||||
|
|
||||||
c := NewChapterFromURL("https://atomicdesign.bradfrost.com/table-of-contents/", "", []*ScrapeConfig{config0, config1}, 0, func(index int, name string) {})
|
c := NewChapterFromURL("https://html5example.com/", "", []*ScrapeConfig{config0, config1}, 0, func(index int, name string) {})
|
||||||
|
|
||||||
got := c.SubChapters()[0].Name()
|
got := c.SubChapters()[0].Name()
|
||||||
want := "About the Author | Atomic Design by Brad Frost"
|
want := "The W3C Markup Validation Service"
|
||||||
|
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("got %v, wanted %v", got, want)
|
t.Errorf("got %v, wanted %v", got, want)
|
||||||
@@ -221,10 +219,9 @@ func TestReverse(t *testing.T) {
|
|||||||
func TestNotInclude(t *testing.T) {
|
func TestNotInclude(t *testing.T) {
|
||||||
|
|
||||||
config := NewScrapeConfig()
|
config := NewScrapeConfig()
|
||||||
config.Selector = "section.concrete > article > h2 > a"
|
|
||||||
config.Include = false
|
config.Include = false
|
||||||
|
|
||||||
c := NewChapterFromURL("https://12factor.net/", "", []*ScrapeConfig{config}, 0, func(index int, name string) {})
|
c := NewChapterFromURL("https://example.com/", "", []*ScrapeConfig{config}, 0, func(index int, name string) {})
|
||||||
|
|
||||||
got := c.Content()
|
got := c.Content()
|
||||||
want := ""
|
want := ""
|
||||||
|
|||||||
Reference in new issue
Block a user