draft/pack_test.go
Hamcha c2d3b3b679
All checks were successful
continuous-integration/drone/tag Build is passing
Add IDs() method for packs
2019-06-28 11:17:51 +02:00

30 lines
698 B
Go

package draft_test
import (
"testing"
"git.fromouter.space/mcg/draft"
)
// TestPackString makes sure packs are serialized correctly
func TestPackString(t *testing.T) {
p := draft.Pack{{ID: "a"}, {ID: "b"}, {ID: "c"}}
expected := "a b c"
if p.String() != expected {
t.Fatalf("Expected \"%s\" but got \"%s\"", expected, p)
}
}
// TestPackIDs makes sure packs are unwrapped correctly
func TestPackIDs(t *testing.T) {
p := draft.Pack{{ID: "a"}, {ID: "b"}, {ID: "c"}}
ids := p.IDs()
if len(ids) < 3 {
t.Fatalf("Expected %d items but got %d", len(p), len(ids))
}
if ids[0] != "a" || ids[1] != "b" || ids[2] != "c" {
t.Fatalf("Contents expected to be [%s] but got %s", p, ids)
}
}