aboutsummaryrefslogtreecommitdiff
path: root/objects
diff options
context:
space:
mode:
authorLaria Carolin Chabowski <laria@laria.me>2017-07-21 07:42:41 +0200
committerLaria Carolin Chabowski <laria@laria.me>2017-07-21 07:42:41 +0200
commitb3c2564730f67e99ef58f8d4e98283680dc96207 (patch)
treecae6cb921791d88971eb9441b802b8862897612e /objects
parent5125eb03724aa38a8ec581c3da88f066d880a993 (diff)
downloadpetrific-b3c2564730f67e99ef58f8d4e98283680dc96207.tar.gz
petrific-b3c2564730f67e99ef58f8d4e98283680dc96207.tar.bz2
petrific-b3c2564730f67e99ef58f8d4e98283680dc96207.zip
Renamed field Container => Archive in snapshots
This is a much better name for what that is
Diffstat (limited to 'objects')
-rw-r--r--objects/object_snapshot.go24
-rw-r--r--objects/object_snapshot_test.go18
2 files changed, 21 insertions, 21 deletions
diff --git a/objects/object_snapshot.go b/objects/object_snapshot.go
index a161f27..18a534f 100644
--- a/objects/object_snapshot.go
+++ b/objects/object_snapshot.go
@@ -10,10 +10,10 @@ import (
)
type Snapshot struct {
- Tree ObjectId
- Date time.Time
- Container string
- Comment string
+ Tree ObjectId
+ Date time.Time
+ Archive string
+ Comment string
}
func (s Snapshot) Type() ObjectType {
@@ -29,7 +29,7 @@ func appendKVPair(b []byte, k, v string) []byte {
}
func (s Snapshot) Payload() (out []byte) {
- out = appendKVPair(out, "container", s.Container)
+ out = appendKVPair(out, "archive", s.Archive)
out = appendKVPair(out, "date", s.Date.Format(time.RFC3339))
out = appendKVPair(out, "tree", s.Tree.String())
@@ -44,7 +44,7 @@ func (s Snapshot) Payload() (out []byte) {
func (s *Snapshot) FromPayload(payload []byte) error {
r := bytes.NewBuffer(payload)
- seenContainer := false
+ seenArchive := false
seenDate := false
seenTree := false
@@ -66,9 +66,9 @@ func (s *Snapshot) FromPayload(payload []byte) error {
headerval := strings.TrimSpace(parts[1])
switch parts[0] {
- case "container":
- s.Container = headerval
- seenContainer = true
+ case "archive":
+ s.Archive = headerval
+ seenArchive = true
case "date":
d, err := time.Parse(time.RFC3339, headerval)
if err != nil {
@@ -90,8 +90,8 @@ func (s *Snapshot) FromPayload(payload []byte) error {
}
}
- if !seenContainer || !seenDate || !seenTree {
- return errors.New("Missing container, date or tree header")
+ if !seenArchive || !seenDate || !seenTree {
+ return errors.New("Missing archive, date or tree header")
}
b := new(bytes.Buffer)
@@ -105,7 +105,7 @@ func (s *Snapshot) FromPayload(payload []byte) error {
func (a Snapshot) Equals(b Snapshot) bool {
return a.Tree.Equals(b.Tree) &&
- a.Container == b.Container &&
+ a.Archive == b.Archive &&
a.Date.Equal(b.Date) &&
a.Comment == b.Comment
}
diff --git a/objects/object_snapshot_test.go b/objects/object_snapshot_test.go
index b610190..df150de 100644
--- a/objects/object_snapshot_test.go
+++ b/objects/object_snapshot_test.go
@@ -8,14 +8,14 @@ import (
var (
testSnapshotObj = Snapshot{
- Comment: "foo\nbar\nbaz!",
- Container: "foo",
- Date: time.Date(2017, 07, 01, 21, 40, 00, 0, time.FixedZone("", 2*60*60)),
- Tree: genId(0xff),
+ Archive: "foo",
+ Comment: "foo\nbar\nbaz!",
+ Date: time.Date(2017, 07, 01, 21, 40, 00, 0, time.FixedZone("", 2*60*60)),
+ Tree: genId(0xff),
}
testSnapshotSerialization = []byte("" +
- "container foo\n" +
+ "archive foo\n" +
"date 2017-07-01T21:40:00+02:00\n" +
"tree sha3-256:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\n" +
"\n" +
@@ -46,10 +46,10 @@ func TestUnserializeSnapshot(t *testing.T) {
func TestUnserializeSnapshotFailure(t *testing.T) {
subtests := []struct{ name, payload string }{
{"empty", ""},
- {"missing tree", "container foo\ndate 2017-07-01T22:02:00+02:00\n"},
- {"missing container", "date 2017-07-01T22:02:00+02:00\ntree sha3-256:0000000000000000000000000000000000000000000000000000000000000000\n"},
- {"missing date", "container foo\ntree sha3-256:0000000000000000000000000000000000000000000000000000000000000000\n"},
- {"invalid date", "container foo\ndate foobar\ntree sha3-256:0000000000000000000000000000000000000000000000000000000000000000\n"},
+ {"missing tree", "archive foo\ndate 2017-07-01T22:02:00+02:00\n"},
+ {"missing archive", "date 2017-07-01T22:02:00+02:00\ntree sha3-256:0000000000000000000000000000000000000000000000000000000000000000\n"},
+ {"missing date", "archive foo\ntree sha3-256:0000000000000000000000000000000000000000000000000000000000000000\n"},
+ {"invalid date", "archive foo\ndate foobar\ntree sha3-256:0000000000000000000000000000000000000000000000000000000000000000\n"},
}
for _, subtest := range subtests {