Change CreationTimestamp to a util.Time and set in each storage implementation

Because time.Time doesn't work correctly with our YAML package, it is necessary
to introduce a type, util.Time, which serializes correctly to JSON and YAML.

Eventually we would like timestamping to cut across storage implementations;
for now, we set it in each storage.
This commit is contained in:
Paul Morie
2014-08-12 15:14:00 -04:00
parent 9355fae71e
commit c69160059b
10 changed files with 262 additions and 22 deletions

View File

@@ -101,10 +101,10 @@ func TestIntOrStringUnmarshalYAML(t *testing.T) {
for _, c := range cases {
var result IntOrStringHolder
if err := yaml.Unmarshal([]byte(c.input), &result); err != nil {
t.Errorf("Failed to unmarshal: %v", err)
t.Errorf("Failed to unmarshal input '%v': %v", c.input, err)
}
if result.IOrS != c.result {
t.Errorf("Failed to unmarshal IntOrString: got %+v", result)
t.Errorf("Failed to unmarshal input '%v': expected: %+v, got %+v", c.input, c.result, result)
}
}
}
@@ -122,10 +122,10 @@ func TestIntOrStringMarshalYAML(t *testing.T) {
input := IntOrStringHolder{c.input}
result, err := yaml.Marshal(&input)
if err != nil {
t.Errorf("Failed to marshal: %v", err)
t.Errorf("Failed to marshal input '%v': %v", input, err)
}
if string(result) != c.result {
t.Errorf("Failed to marshal IntOrString: got %q", string(result))
t.Errorf("Failed to marshal input '%v': expected: %+v, got %q", input, c.result, string(result))
}
}
}
@@ -142,10 +142,10 @@ func TestIntOrStringUnmarshalJSON(t *testing.T) {
for _, c := range cases {
var result IntOrStringHolder
if err := json.Unmarshal([]byte(c.input), &result); err != nil {
t.Errorf("Failed to unmarshal: %v", err)
t.Errorf("Failed to unmarshal input '%v': %v", c.input, err)
}
if result.IOrS != c.result {
t.Errorf("Failed to unmarshal IntOrString: got %+v", result)
t.Errorf("Failed to unmarshal input '%v': expected %+v, got %+v", c.input, c.result, result)
}
}
}
@@ -163,10 +163,10 @@ func TestIntOrStringMarshalJSON(t *testing.T) {
input := IntOrStringHolder{c.input}
result, err := json.Marshal(&input)
if err != nil {
t.Errorf("Failed to marshal: %v", err)
t.Errorf("Failed to marshal input '%v': %v", input, err)
}
if string(result) != c.result {
t.Errorf("Failed to marshal IntOrString: got %q", string(result))
t.Errorf("Failed to marshal input '%v': expected: %+v, got %q", input, c.result, string(result))
}
}
}