Contains the Concourse pipeline definition for building a line-server container
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.

47 lines
993 B

  1. package main
  2. import (
  3. "fmt"
  4. "testing"
  5. "github.com/zeebo/bencode"
  6. )
  7. func TestCreateTorrent(t *testing.T) {
  8. fileName := "server.go"
  9. var decoded Torrent
  10. encoded, err := CreateTorrent(fileName, fileName)
  11. if err != nil {
  12. t.Fatal(err)
  13. }
  14. bencode.DecodeBytes(encoded, &decoded)
  15. if decoded.Encoding != "UTF-8" {
  16. t.Fatalf("Encoding was %s, expected UTF-8", decoded.Encoding)
  17. }
  18. if decoded.Info.Name != "server.go" {
  19. t.Fatalf("Name was %s, expected server.go", decoded.Info.Name)
  20. }
  21. if decoded.Info.PieceLength <= 0 {
  22. t.Fatal("Expected a piece length, got none")
  23. }
  24. if len(decoded.Info.Pieces) <= 0 {
  25. t.Fatal("Expected at least one piece, got none")
  26. }
  27. if decoded.Info.Length <= 0 {
  28. t.Fatal("Length was less than or equal to 0, expected more")
  29. }
  30. tracker := fmt.Sprintf("%sselif/%s", Config.siteURL, fileName)
  31. if decoded.UrlList[0] != tracker {
  32. t.Fatalf("First entry in URL list was %s, expected %s", decoded.UrlList[0], tracker)
  33. }
  34. }
  35. // vim:set ts=8 sw=8 noet: