draft/pack_test.go

31 lines
698 B
Go
Raw Normal View History

2019-06-28 09:17:51 +00:00
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)
}
}