-
Notifications
You must be signed in to change notification settings - Fork 0
/
release_log_test.go
49 lines (46 loc) · 1.68 KB
/
release_log_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package contracts
import (
"encoding/json"
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestReleaseLog(t *testing.T) {
t.Run("JSONMarshalSingleReleaseLog", func(t *testing.T) {
releaseLog := ReleaseLog{
ID: "5",
RepoSource: "github.com",
RepoOwner: "estafette",
RepoName: "estafette-ci-api",
ReleaseID: "123445",
Steps: []*BuildLogStep{
&BuildLogStep{
Step: "deploy",
Image: &BuildLogStepDockerImage{
Name: "golang",
Tag: "1.10.2-alpine3.7",
IsPulled: false,
ImageSize: 135000,
PullDuration: 2 * time.Second,
Error: "",
},
Duration: 91 * time.Second,
LogLines: []BuildLogLine{
BuildLogLine{
Timestamp: time.Date(2018, 4, 17, 8, 3, 0, 0, time.UTC),
StreamType: "stdout",
Text: "ok github.com/estafette/estafette-ci-contracts 0.017s",
},
},
ExitCode: 0,
Status: "SUCCEEDED",
},
},
InsertedAt: time.Date(2018, 4, 17, 8, 3, 0, 0, time.UTC),
}
// act
bytes, err := json.Marshal(&releaseLog)
assert.Nil(t, err)
assert.Equal(t, "{\"id\":\"5\",\"repoSource\":\"github.com\",\"repoOwner\":\"estafette\",\"repoName\":\"estafette-ci-api\",\"releaseID\":\"123445\",\"steps\":[{\"step\":\"deploy\",\"image\":{\"name\":\"golang\",\"tag\":\"1.10.2-alpine3.7\",\"isPulled\":false,\"imageSize\":135000,\"pullDuration\":2000000000},\"duration\":91000000000,\"logLines\":[{\"timestamp\":\"2018-04-17T08:03:00Z\",\"streamType\":\"stdout\",\"text\":\"ok \\tgh.neting.cc/estafette/estafette-ci-contracts\\t0.017s\"}],\"exitCode\":0,\"status\":\"SUCCEEDED\"}],\"insertedAt\":\"2018-04-17T08:03:00Z\"}", string(bytes))
})
}