You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.1 KiB

  1. package pad2ipfs
  2. import (
  3. "fmt"
  4. "testing"
  5. "github.com/fatih/color"
  6. )
  7. const checkIcon = "\xE2\x9C\x94 "
  8. func TestGenerateEmptyMT(t *testing.T) {
  9. hash1, err := Add("http://board.net/p/pad1", "md")
  10. if err != nil {
  11. t.Errorf(err.Error())
  12. } else {
  13. color.Green(checkIcon + "added file1")
  14. fmt.Print(" IPFS hash:")
  15. color.Blue(hash1)
  16. }
  17. hash2, err := Add("http://board.net/p/pad2", "txt")
  18. if err != nil {
  19. t.Errorf(err.Error())
  20. } else {
  21. color.Green(checkIcon + "added file2")
  22. fmt.Print(" IPFS hash:")
  23. color.Blue(hash2)
  24. }
  25. hash3, err := Add("http://board.net/p/pad3", "html")
  26. if err != nil {
  27. t.Errorf(err.Error())
  28. } else {
  29. color.Green(checkIcon + "added file3")
  30. fmt.Print(" IPFS hash:")
  31. color.Blue(hash3)
  32. }
  33. err = Get(hash1, "pad1.md")
  34. if err != nil {
  35. t.Errorf(err.Error())
  36. } else {
  37. color.Green(checkIcon + "getted file1")
  38. }
  39. err = Get(hash2, "pad2.txt")
  40. if err != nil {
  41. t.Errorf(err.Error())
  42. } else {
  43. color.Green(checkIcon + "getted file2")
  44. }
  45. err = Get(hash3, "pad3.html")
  46. if err != nil {
  47. t.Errorf(err.Error())
  48. } else {
  49. color.Green(checkIcon + "getted file3")
  50. }
  51. }