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.

34 lines
661 B

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