Browse Source

Fix travis-ci duration parsing

The example from the docs was very clearly with spaces after hours and minutes:
```
  "committed_at": "2011-11-11T11: 11: 11Z",
```
But in fact those spaces do not exist in the wild. Great.
kegan/text-logging
Kegan Dougal 8 years ago
parent
commit
61c3110cfe
  1. 6
      src/github.com/matrix-org/go-neb/services/travisci/travisci.go
  2. 5
      src/github.com/matrix-org/go-neb/services/travisci/travisci_test.go

6
src/github.com/matrix-org/go-neb/services/travisci/travisci.go

@ -133,9 +133,9 @@ func notifToTemplate(n webhookNotification) map[string]string {
if n.StartedAt != nil && n.FinishedAt != nil {
// duration: total duration of all builds in the matrix -- TODO
// elapsed_time: time between build start and finish
// Example from docs: "2011-11-11T11: 11: 11Z"
start, err := time.Parse("2006-01-02T15: 04: 05Z", *n.StartedAt)
finish, err2 := time.Parse("2006-01-02T15: 04: 05Z", *n.FinishedAt)
// Example from docs: "2011-11-11T11:11:11Z"
start, err := time.Parse("2006-01-02T15:04:05Z", *n.StartedAt)
finish, err2 := time.Parse("2006-01-02T15:04:05Z", *n.FinishedAt)
if err != nil || err2 != nil {
log.WithFields(log.Fields{
"started_at": *n.StartedAt,

5
src/github.com/matrix-org/go-neb/services/travisci/travisci_test.go

@ -84,6 +84,11 @@ var travisTests = []struct {
"%{repository}#%{build_number} (%{branch} - %{commit} : %{author}): %{message}",
"Kegsay/flow-jsdoc#18 (master - 3a092c3a6032ebb50384c99b445f947e9ce86e2a : Kegan Dougal): Passed",
},
{
exampleSignature, true, exampleBody,
"%{repository}#%{build_number} %{duration}",
"Kegsay/flow-jsdoc#18 32s",
},
}
type MockTransport struct {

Loading…
Cancel
Save