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.

33 lines
655 B

  1. package data
  2. import (
  3. "encoding/json"
  4. "strings"
  5. "testing"
  6. )
  7. func TestPublishAndRetrieve(t *testing.T) {
  8. t.Log("Testing adding json")
  9. exampleVote := votePacket{
  10. 000001,
  11. "12309801002",
  12. "nynnynnnynnnyy",
  13. "132498-0-02103908",
  14. }
  15. testObject, err := json.Marshal(exampleVote)
  16. if err != nil {
  17. t.Errorf("Bad test JSON: %s", err)
  18. }
  19. prepub := string(testObject)
  20. hash := publish(testObject)
  21. content := retrieve(hash)
  22. postpub := string(content)
  23. //fmt.Println(hash)
  24. //fmt.Println(string(content))
  25. if strings.Compare(prepub, postpub) != 0 {
  26. t.Errorf("Published file doesn't match. Expected:\n %s \n Got: \n %s \n", prepub, postpub)
  27. }
  28. }