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.

43 lines
952 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. encoded := CreateTorrent(fileName, fileName)
  10. var decoded Torrent
  11. bencode.DecodeBytes(encoded, &decoded)
  12. if decoded.Encoding != "UTF-8" {
  13. t.Fatalf("Encoding was %s, expected UTF-8", decoded.Encoding)
  14. }
  15. if decoded.Info.Name != "server.go" {
  16. t.Fatalf("Name was %s, expected server.go", decoded.Info.Name)
  17. }
  18. if decoded.Info.PieceLength <= 0 {
  19. t.Fatal("Expected a piece length, got none")
  20. }
  21. if len(decoded.Info.Pieces) <= 0 {
  22. t.Fatal("Expected at least one piece, got none")
  23. }
  24. if decoded.Info.Length <= 0 {
  25. t.Fatal("Length was less than or equal to 0, expected more")
  26. }
  27. tracker := fmt.Sprintf("%sselif/%s", Config.siteURL, fileName)
  28. if decoded.UrlList[0] != tracker {
  29. t.Fatalf("First entry in URL list was %s, expected %s", decoded.UrlList[0], tracker)
  30. }
  31. }
  32. // vim:set ts=8 sw=8 noet: