1
0

wiki_test.go 565 B

123456789101112131415161718192021222324252627
  1. package db
  2. import (
  3. "testing"
  4. "github.com/stretchr/testify/require"
  5. )
  6. func TestToWikiPageName(t *testing.T) {
  7. tests := []struct {
  8. input string
  9. want string
  10. }{
  11. {input: "Home", want: "Home"},
  12. {input: "../../../../tmp/target_file", want: "tmp target_file"},
  13. {input: "..\\..\\..\\..\\tmp\\target_file", want: "tmp target_file"},
  14. {input: "A/B", want: "A B"},
  15. {input: "../pwn", want: "pwn"},
  16. }
  17. for _, test := range tests {
  18. t.Run(test.input, func(t *testing.T) {
  19. got := ToWikiPageName(test.input)
  20. require.Equal(t, test.want, got)
  21. })
  22. }
  23. }