postprocessing_test.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. Copyright 2017 The Kubernetes Authors.
  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 at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package main
  14. import (
  15. "testing"
  16. )
  17. func TestCleanupForInclude(t *testing.T) {
  18. var tests = []struct {
  19. markdown, expectedMarkdown string
  20. }{
  21. { // first line is removed
  22. // Nb. first line is the title of the document, and by removing it you get
  23. // more flexibility for include, e.g. include in tabs
  24. markdown: "line 1\n" +
  25. "line 2\n" +
  26. "line 3",
  27. expectedMarkdown: "line 2\n" +
  28. "line 3",
  29. },
  30. { // everything after ###SEE ALSO is removed
  31. // Nb. see also, that assumes file will be used as a main page (does not apply to includes)
  32. markdown: "line 1\n" +
  33. "line 2\n" +
  34. "### SEE ALSO\n" +
  35. "line 3",
  36. expectedMarkdown: "line 2\n",
  37. },
  38. }
  39. for _, rt := range tests {
  40. actual := cleanupForInclude(rt.markdown)
  41. if actual != rt.expectedMarkdown {
  42. t.Errorf(
  43. "failed cleanupForInclude:\n\texpected: %s\n\t actual: %s",
  44. rt.expectedMarkdown,
  45. actual,
  46. )
  47. }
  48. }
  49. }